Skip to content

Commit

Permalink
auth fields as hex
Browse files Browse the repository at this point in the history
  • Loading branch information
containerman17 committed Oct 3, 2024
1 parent 12000c8 commit cd2211e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions crypto/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/hdevalence/ed25519consensus"

"github.com/ava-labs/hypersdk/codec"
"github.com/ava-labs/hypersdk/crypto"
)

Expand Down Expand Up @@ -98,3 +99,29 @@ func (b *Batch) VerifyAsync() func() error {
return nil
}
}

func (p PublicKey) MarshalText() ([]byte, error) {
return []byte(codec.ToHex(p[:])), nil
}

func (p *PublicKey) UnmarshalText(text []byte) error {
bytes, err := codec.LoadHex(string(text), PublicKeyLen)
if err != nil {
return err
}
copy(p[:], bytes)
return nil
}

func (s Signature) MarshalText() ([]byte, error) {
return []byte(codec.ToHex(s[:])), nil
}

func (s *Signature) UnmarshalText(text []byte) error {
bytes, err := codec.LoadHex(string(text), SignatureLen)
if err != nil {
return err
}
copy(s[:], bytes)
return nil
}

0 comments on commit cd2211e

Please sign in to comment.