Skip to content

Commit

Permalink
feat: access raw verifier bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Oct 17, 2024
1 parent 2be8af8 commit e9b4aa0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions principal/ed25519/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ func (v Ed25519Verifier) DID() did.DID {
func (v Ed25519Verifier) Encode() []byte {
return v
}

func (s Ed25519Verifier) Raw() []byte {
k := make(ed25519.PublicKey, ed25519.PublicKeySize)
copy(k, s[publicTagSize:])
return k
}
2 changes: 2 additions & 0 deletions principal/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ type Verifier interface {
ucan.Verifier
Code() uint64
Encode() []byte
// Raw encodes the bytes of the public key without multiformats tags.
Raw() []byte
}
5 changes: 5 additions & 0 deletions principal/rsa/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ func (v rsaverifier) DID() did.DID {
func (v rsaverifier) Encode() []byte {
return v.bytes
}

func (v rsaverifier) Raw() []byte {
b, _ := multiformat.UntagWith(Code, v.bytes, 0)
return b
}
4 changes: 4 additions & 0 deletions principal/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (w wrapvf) Encode() []byte {
return w.key.Encode()
}

func (w wrapvf) Raw() []byte {
return w.key.Raw()
}

func (w wrapvf) Verify(msg []byte, sig signature.Signature) bool {
return w.key.Verify(msg, sig)
}
Expand Down

0 comments on commit e9b4aa0

Please sign in to comment.