diff --git a/Readme.md b/Readme.md index 72e7a7a..1adbd82 100644 --- a/Readme.md +++ b/Readme.md @@ -1,3 +1,30 @@ +
+ +This is an implementation of Decentralized Identifiers (DIDs) in go. It differs from the alternatives in the following ways: +- **simple**: made of shared reusable components and clear interfaces +- **fast**: while it supports DID Documents as JSON files, it's not unnecessary in the way (see below) +- **support producing and using DIDs**: unlike some others, this all-in-one implementation is meant to create, manipulate and handle DIDs +- **extensible**: you can easily register your custom DID method DID spec concepts: diff --git a/verifications/ed25519/VerificationKey2020.go b/verifications/ed25519/VerificationKey2020.go index f75490e..0f861f8 100644 --- a/verifications/ed25519/VerificationKey2020.go +++ b/verifications/ed25519/VerificationKey2020.go @@ -100,12 +100,14 @@ func (v VerificationKey2020) Verify(data []byte, sig []byte) bool { return ed25519.Verify(v.pubkey, data, sig) } +// encodePubkey encodes the public key in a suitable way for publicKeyMultibase func encodePubkey(pubkey ed25519.PublicKey) string { // can only fail with an invalid encoding, but it's hardcoded bytes, _ := mbase.Encode(mbase.Base58BTC, append(varint.ToUvarint(MultibaseCode), pubkey...)) return bytes } +// decodePubkey decodes the public key from its publicKeyMultibase form func decodePubkey(encoded string) (ed25519.PublicKey, error) { baseCodec, bytes, err := mbase.Decode(encoded) if err != nil {