Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change new identity keys to hex format #2773

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions acp/identity/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@

package identity

import "github.com/sourcenetwork/defradb/crypto"
import (
"encoding/hex"

"github.com/sourcenetwork/defradb/crypto"
)

// RawIdentity holds the raw bytes that make up an actor's identity.
type RawIdentity struct {
// An actor's private key.
PrivateKey []byte
// PrivateKey is a secp256k1 private key that is a 256-bit big-endian
// binary-encoded number, padded to a length of 32 bytes in HEX format.
PrivateKey string

// An actor's corresponding public key address.
PublicKey []byte
// PublicKey is a compressed 33-byte secp256k1 public key in HEX format.
PublicKey string

// An actor's DID. Generated from the public key address.
// DID is `did:key` key generated from the public key address.
DID string
}

Expand All @@ -43,8 +48,8 @@ func Generate() (RawIdentity, error) {
newIdentity := maybeNewIdentity.Value()

return RawIdentity{
PrivateKey: newIdentity.PrivateKey.Serialize(),
PublicKey: newIdentity.PublicKey.SerializeUncompressed(),
PrivateKey: hex.EncodeToString(newIdentity.PrivateKey.Serialize()),
PublicKey: hex.EncodeToString(newIdentity.PublicKey.SerializeCompressed()),
DID: newIdentity.DID,
}, nil
}
Loading