Skip to content

Commit

Permalink
added eip712 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bunfield committed Jul 9, 2024
1 parent 1c67c23 commit da1d98e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions test/simulator/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func (n nodeSigner) Sign(sig protocol.Signature, sigMdHash, message []byte) erro
case *protocol.ETHSignature:
return protocol.SignETH(sig, k, sigMdHash, message)

case *protocol.Eip712TypedDataSignature:
return protocol.SignEip712TypedData(sig, k, sigMdHash, message)

default:
return fmt.Errorf("cannot sign %T with a key", sig)
}
Expand Down
26 changes: 13 additions & 13 deletions test/testing/fake_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ func (f *FakeTransactionBody) Type() protocol.TransactionType { return f.TheType
var _ protocol.Signature = (*FakeSignature)(nil)
var _ protocol.KeySignature = (*FakeSignature)(nil)

func (f *FakeSignature) Type() protocol.SignatureType { return f.TheType }
func (f *FakeSignature) GetVote() protocol.VoteType { return f.Vote }
func (f *FakeSignature) Verify(sigMdHash, hash []byte) bool { return true }
func (f *FakeSignature) Hash() []byte { return make([]byte, 32) }
func (f *FakeSignature) Metadata() protocol.Signature { return f }
func (f *FakeSignature) Initiator() (hash.Hasher, error) { return nil, nil }
func (f *FakeSignature) GetSigner() *url.URL { return f.Signer }
func (f *FakeSignature) RoutingLocation() *url.URL { return f.Signer }
func (f *FakeSignature) GetSignerVersion() uint64 { return f.SignerVersion }
func (f *FakeSignature) GetTimestamp() uint64 { return f.Timestamp }
func (f *FakeSignature) GetPublicKey() []byte { return f.PublicKey }
func (f *FakeSignature) GetSignature() []byte { return make([]byte, 32) }
func (f *FakeSignature) GetTransactionHash() [32]byte { return [32]byte{} }
func (f *FakeSignature) Type() protocol.SignatureType { return f.TheType }
func (f *FakeSignature) GetVote() protocol.VoteType { return f.Vote }
func (f *FakeSignature) Verify(sigMdHash, hash []byte, txn *protocol.Transaction) bool { return true }
func (f *FakeSignature) Hash() []byte { return make([]byte, 32) }
func (f *FakeSignature) Metadata() protocol.Signature { return f }
func (f *FakeSignature) Initiator() (hash.Hasher, error) { return nil, nil }
func (f *FakeSignature) GetSigner() *url.URL { return f.Signer }
func (f *FakeSignature) RoutingLocation() *url.URL { return f.Signer }
func (f *FakeSignature) GetSignerVersion() uint64 { return f.SignerVersion }
func (f *FakeSignature) GetTimestamp() uint64 { return f.Timestamp }
func (f *FakeSignature) GetPublicKey() []byte { return f.PublicKey }
func (f *FakeSignature) GetSignature() []byte { return make([]byte, 32) }
func (f *FakeSignature) GetTransactionHash() [32]byte { return [32]byte{} }

func (f *FakeSignature) GetPublicKeyHash() []byte {
if f.Type() == protocol.SignatureTypeRCD1 {
Expand Down

0 comments on commit da1d98e

Please sign in to comment.