-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f001109
commit e2febc3
Showing
3 changed files
with
40 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package identity | ||
|
||
import ( | ||
"encoding/hex" | ||
|
||
"github.com/decred/dcrd/dcrec/secp256k1/v4" | ||
) | ||
|
||
// RawIdentity holds the raw bytes that make up an actor's identity. | ||
type RawIdentity struct { | ||
// 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 | ||
|
||
// PublicKey is a compressed 33-byte secp256k1 public key in HEX format. | ||
PublicKey string | ||
|
||
// DID is `did:key` key generated from the public key address. | ||
DID string | ||
} | ||
|
||
func newRawIdentity(privateKey *secp256k1.PrivateKey, publicKey *secp256k1.PublicKey, did string) RawIdentity { | ||
return RawIdentity{ | ||
PrivateKey: hex.EncodeToString(privateKey.Serialize()), | ||
PublicKey: hex.EncodeToString(publicKey.SerializeCompressed()), | ||
DID: did, | ||
} | ||
} |