Documentation ¶
Index ¶
- Constants
- func Check(signature []byte, msg []byte, decompressedPublicKey []byte) bool
- func Decrypt(ciphered, privateKey, decompressedPublicKey []byte) ([]byte, error)
- func ECDSAPrivateKeyFrom(privateKeyBytes, publicKeyBytes []byte) (sk ecdsa.PrivateKey, err error)
- func ECDSAPublicKeyFrom(publicKeyBytes []byte) (pk ecdsa.PublicKey, err error)
- func ECIESKeyPairFrom(ecdsaPublicKBytes, ecdsaPrivateKBytes []byte) (pubkey ecies.PublicKey, privkey ecies.PrivateKey, err error)
- func Encrypt(msg, decompressedPublicKey []byte) ([]byte, error)
- func GenerateKeyPair(seed []byte, path Path) (pubkey, privkey []byte, err error)
- func GenerateRandomKeyPair() (pubkey, privkey []byte, err error)
- func Hash(input []byte) ([]byte, error)
- func ImportSignature(input []byte) (signature []byte, err error)
- func IsCompatibleKeyPair(pk, sk []byte) bool
- func IsHashedValue(str string) bool
- func ParsePrivateKey(base58PrivateKey string) (pubkey []byte, err error)
- func ParsePublicKey(base58PublicKey string) (pubkey []byte, err error)
- func ParsePublicKeyFromCompressed(str string) (pubkey []byte, err error)
- func SSHPublicKey2String(pk ssh.PublicKey) string
- func Sign(msg []byte, secretKey []byte) ([]byte, error)
- type Account
- type Indices
- type Path
Constants ¶
const ( // SEED_TEST_STRING ... SEED_TEST_STRING = "e5dcc2bdf7310ea3abc82a3580621bd0a487c181113d889d0775d3f8eba21e84" // IDKEY_TEST_STRING ... IDKEY_TEST_STRING = "68403eeafc1431eb85aabd250480752b3950f50463023a42f4d4d3b301544451" // PATH_1_STRING ... PATH_1_STRING = "m/0'/0/0" // PUBLIC_DECOMPRESSED_KEY_1_STRING ... PUBLIC_DECOMPRESSED_KEY_1_STRING = "" /* 130-byte string literal not displayed */ // PUBLIC_COMPRESSED_KEY_1_STRING ... PUBLIC_COMPRESSED_KEY_1_STRING = "03e315a987bd79b9f49d3a1c8bd1ef5a401a242820d52a3f22505da81dfcd992cc" // SECRET_KEY_1_STRING ... SECRET_KEY_1_STRING = "b9fc3b425d6c1745b9c963c97e6e1d4c1db7a093a36e0cf7c0bf85dc1130b8a0" )
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check verifies the validity of the signature of a given content with a public key.
It takes the signature, the content that was signed and the decompressed public key to use as arguments and returns true if it checks out. It's the verifying counterpart of the Sig() function. Therefore, as of the latest version, it takes an ECDSA signature in 64-byte [R||S] format and its associated decompressed public key in byte array and hashes the content message with the system's Hash() function before using it.
func Decrypt ¶
Decrypt recovers data encrypted with ECIES algorithm using the private key and the decompressed public key TODO Try not to use the public key, only the private
func ECDSAPrivateKeyFrom ¶
func ECDSAPrivateKeyFrom(privateKeyBytes, publicKeyBytes []byte) (sk ecdsa.PrivateKey, err error)
ECDSAPrivateKeyFrom ...
func ECDSAPublicKeyFrom ¶
ECDSAPublicKeyFrom ...
func ECIESKeyPairFrom ¶
func ECIESKeyPairFrom(ecdsaPublicKBytes, ecdsaPrivateKBytes []byte) (pubkey ecies.PublicKey, privkey ecies.PrivateKey, err error)
ECIESKeyPairFrom transforms an ECDSA keypair in byte array to its ECIES counterparts.
It takes a keypair in byte array and returns the ECIES PublicKey and PrivateKey objects, and an error if something went wrong. Keys generated through the GenerateKeyPair() function should be compatible.
func GenerateKeyPair ¶
GenerateKeyPair is the function that should be used whenever a keypair is needed in the Rooot project.
It takes a seed (ie. the master key in Rooot) and a BIP-32 path, and returns a keypair in byte array, decompressed public and private, and an error if any. As of the latest version in the system, this keypair operates on Bitcoin's secp256k1 elliptic curve. It shall be used for either signing with ECDSA or encrypting/decrypting with ECIES. One should use the utils.ToHex() utility method to save any of these byte arrays as their hexadecimal string representation if needed.
func GenerateRandomKeyPair ¶
GenerateRandomKeyPair generates a random keypair
func Hash ¶
Hash is the hashing function that should be used whenever hashing in the Rooot™ project.
It takes a byte array as argument and returns a byte array and an error if any. As of the latest version of the system, it double-hashes any input string with the SHA256 standard algorithm. One should use the utils.ToHex() utility method to save the byte array as its hexadecimal string representation.
func ImportSignature ¶
ImportSignature parses a DER ECDSA signature as in `ecies-geth` JavaScript module to produce the appropriate 64-byte [R||S] signature @see https://github.com/cryptocoinjs/secp256k1-node/blob/90a04a2e1127f4c1bfd7015aa5a7b22d08edb811/lib/elliptic.js
func IsCompatibleKeyPair ¶
IsCompatibleKeyPair tests whether a decompressed public key and a private key form an actual valid keypair.
func ParsePrivateKey ¶
ParsePrivateKey ...
func ParsePublicKey ¶
ParsePublicKey ...
func ParsePublicKeyFromCompressed ¶
ParsePublicKeyFromCompressed ...
func SSHPublicKey2String ¶ added in v1.4.12
SSHPublicKey2String returns the stringified version of the passed SSH public key
func Sign ¶
Sign signs a content using secp256k1 elliptic curve.
It takes the content to sign and the secret key to use as arguments and returns the signature and an error if any. As of the latest version of the system, it first hashes the content message with the system's Hash() function, then signs it using Bitcoin's secp256k1 elliptic curve that returns a recoverable ECDSA signature in 65-byte [R||S||V] format, and finally gets rid of the recovery 65th byte (the V).
Types ¶
type Path ¶
type Path string
Path is the string representation of a BIP32 path, eg. `m/0'/0/0`. NB: For compatibility reasons with browsers, the account number and the scope mustn't be greater than 2^16 - 1 and the key index not greater than 2^21 - 1.