Skip to content

Commit

Permalink
Adding support for evmnet
Browse files Browse the repository at this point in the history
  • Loading branch information
AnomalRoil committed Oct 18, 2024
1 parent 24c8c6e commit cb855fe
Show file tree
Hide file tree
Showing 8 changed files with 545 additions and 23 deletions.
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 @@ func NewNetwork(chainHash string, publicKey kyber.Point, sch *crypto.Scheme, per
case crypto.ShortSigSchemeID:
case crypto.SigsOnG1ID:
case crypto.UnchainedSchemeID:
case crypto.BN254UnchainedOnG1SchemeID:
default:
return nil, ErrNotUnchained
}
Expand All @@ -45,6 +47,36 @@ func NewNetwork(chainHash string, publicKey kyber.Point, sch *crypto.Scheme, per
}, 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

0 comments on commit cb855fe

Please sign in to comment.