Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for evmnet #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions networks/fixed/fixed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package fixed

import (
"encoding/json"
"errors"
"time"

Expand Down Expand Up @@ -31,6 +32,7 @@
case crypto.ShortSigSchemeID:
case crypto.SigsOnG1ID:
case crypto.UnchainedSchemeID:
case crypto.BN254UnchainedOnG1SchemeID:
default:
return nil, ErrNotUnchained
}
Expand All @@ -45,6 +47,36 @@
}, nil
}

type infoV2 struct {
PublicKey chain.HexBytes `json:"public_key"`
ID string `json:"beacon_id,beaconID"`

Check failure on line 52 in networks/fixed/fixed.go

View workflow job for this annotation

GitHub Actions / build

unknown JSON option "beaconID" (SA5008)
Period int64 `json:"period"`
Scheme string `json:"scheme"`
GenesisTime int64 `json:"genesis_time"`
ChainHash string `json:"chain_hash,hash"`

Check failure on line 56 in networks/fixed/fixed.go

View workflow job for this annotation

GitHub Actions / build

unknown JSON option "hash" (SA5008)
}

func FromInfo(jsonInfo string) (*Network, error) {
info := new(infoV2)
err := json.Unmarshal([]byte(jsonInfo), info)
if err != nil {
return nil, err
}
sch, err := crypto.SchemeFromName(info.Scheme)
if err != nil {
return nil, err
}
public := sch.KeyGroup.Point()
if err := public.UnmarshalBinary(info.PublicKey); err != nil {
return nil, err
}
return NewNetwork(info.ChainHash, public, sch, time.Duration(info.Period)*time.Second, info.GenesisTime, nil)
}

func (n *Network) SetSignature(sig []byte) {
n.fixedSig = sig
}

// ChainHash returns the chain hash for this network.
func (n *Network) ChainHash() string {
return n.chainHash
Expand Down
Loading
Loading