Skip to content

Commit

Permalink
update embed vks from curie to darwin v0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amoylan2 committed Aug 20, 2024
1 parent 5bd31f7 commit 3607a57
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions coordinator/internal/logic/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func NewLoginLogic(db *gorm.DB, cfg *config.Config, vf *verifier.Verifier) *Logi
challengeOrm: orm.NewChallenge(db),
}

for _, vk := range vf.ChunkVKMap {
for vk := range vf.ChunkVKMap {
l.chunkVks[vk] = struct{}{}
}

for _, vk := range vf.BatchVKMap {
for vk := range vf.BatchVKMap {
l.batchVKs[vk] = struct{}{}
}

for _, vk := range vf.BundleVkMap {
for vk := range vf.BundleVkMap {
l.bundleVks[vk] = struct{}{}
}

Expand Down
Binary file not shown.
7 changes: 4 additions & 3 deletions coordinator/internal/logic/verifier/legacy_vk/upgrade_vks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ echo $work_dir

rm $work_dir/*.vkey

version=release-v0.11.4
wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/chunk_vk.vkey -O $work_dir/chunk_vk.vkey
wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/agg_vk.vkey -O $work_dir/agg_vk.vkey
version=release-v0.12.0
wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/vk_chunk.vkey -O $work_dir/vk_chunk.vkey
wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/vk_batch.vkey -O $work_dir/vk_batch.vkey
wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/vk_bundle.vkey -O $work_dir/vk_bundle.vkey
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions coordinator/internal/logic/verifier/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const InvalidTestProof = "this is a invalid proof"
// Verifier represents a rust ffi to a halo2 verifier.
type Verifier struct {
cfg *config.VerifierConfig
ChunkVKMap map[string]string
BatchVKMap map[string]string
BundleVkMap map[string]string
ChunkVKMap map[string]struct{}
BatchVKMap map[string]struct{}
BundleVkMap map[string]struct{}
}
28 changes: 18 additions & 10 deletions coordinator/internal/logic/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {

v := &Verifier{
cfg: cfg,
ChunkVKMap: make(map[string]string),
BatchVKMap: make(map[string]string),
BundleVkMap: make(map[string]string),
ChunkVKMap: make(map[string]struct{}),
BatchVKMap: make(map[string]struct{}),
BundleVkMap: make(map[string]struct{}),
}

bundleVK, err := v.readVK(path.Join(cfg.HighVersionCircuit.AssetsPath, "vk_bundle.vkey"))
Expand All @@ -77,9 +77,9 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
if err != nil {
return nil, err
}
v.BundleVkMap[cfg.ForkName] = bundleVK
v.BatchVKMap[cfg.ForkName] = batchVK
v.ChunkVKMap[cfg.ForkName] = chunkVK
v.BundleVkMap[bundleVK] = struct{}{}
v.BatchVKMap[batchVK] = struct{}{}
v.ChunkVKMap[chunkVK] = struct{}{}

if err := v.loadEmbedVK(); err != nil {
return nil, err
Expand Down Expand Up @@ -190,19 +190,27 @@ func (v *Verifier) readVK(filePat string) (string, error) {
var legacyVKFS embed.FS

func (v *Verifier) loadEmbedVK() error {
batchVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/agg_vk.vkey")
chunkVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_chunk.vkey")
if err != nil {
log.Error("load embed chunk vk failure", "err", err)
return err
}

batchVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_batch.vkey")
if err != nil {
log.Error("load embed batch vk failure", "err", err)
return err
}

chunkVkBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/chunk_vk.vkey")
bundleVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_bundle.vkey")
if err != nil {
log.Error("load embed chunk vk failure", "err", err)
return err
}

v.BatchVKMap["curie"] = base64.StdEncoding.EncodeToString(batchVKBytes)
v.ChunkVKMap["curie"] = base64.StdEncoding.EncodeToString(chunkVkBytes)
v.ChunkVKMap[base64.StdEncoding.EncodeToString(chunkVKBytes)] = struct{}{}
v.BatchVKMap[base64.StdEncoding.EncodeToString(batchVKBytes)] = struct{}{}
v.BundleVkMap[base64.StdEncoding.EncodeToString(bundleVKBytes)] = struct{}{}

return nil
}

0 comments on commit 3607a57

Please sign in to comment.