FrostFS crypto library
Find a file
Vitaliy Potyarkin 3c047deab9 [#10] Add CODEOWNERS
Signed-off-by: Vitaliy Potyarkin <v.potyarkin@yadro.com>
2024-12-10 18:48:38 +03:00
internal initial 2019-10-22 17:40:05 +03:00
test initial 2019-10-22 17:40:05 +03:00
CODEOWNERS [#10] Add CODEOWNERS 2024-12-10 18:48:38 +03:00
CONTRIBUTING.md [#4] Add CONTRIBUTING.md 2024-08-30 14:02:11 +03:00
ecdsa.go Rename package name 2023-03-07 12:57:09 +03:00
ecdsa_test.go Rename package name 2023-03-07 12:57:09 +03:00
go.mod Rename package name 2023-03-07 12:57:09 +03:00
go.sum Rename package name 2023-03-07 12:57:09 +03:00
LICENSE initial 2019-10-22 17:40:05 +03:00
load.go Fix tests on go1.19 (#16) 2022-08-15 14:49:39 +03:00
load_test.go Rename package name 2023-03-07 12:57:09 +03:00
README.md doc: Fix RFC6979 signature size in readme file 2020-03-02 13:38:38 +03:00
rfc6979.go Rename package name 2023-03-07 12:57:09 +03:00
rfc6979_test.go Rename package name 2023-03-07 12:57:09 +03:00
SECURITY.md [#3] Add SECURITY.md 2024-09-17 07:39:47 +00:00
wif.go Rename package name 2023-03-07 12:57:09 +03:00
wif_test.go Rename package name 2023-03-07 12:57:09 +03:00

NeoFS Crypto library

This package contains useful methods to work with crypto-primitives, that used in NeoFS / NeoBlockchain.

Examples

Simple Marshal / Unmarshal ECDSA public key (PK):

// returns slice of 33 bytes marshaled public key
data := crypto.MarshalPublicKey(&sk.PublicKey)

// returns public key decoded from 33 bytes    
pk := crypto.UnmarshalPublicKey(data)

Simple Marshal / Unmarshal ECDSA private key (SK):

// returns slice of 32 bytes marshaled private key
data := crypto.MarshalPrivateKey(&sk)

// returns private key decoded from 32 bytes or error,
// if something whet wrong    
newSk, err := crypto.UnmarshalPrivateKey(data)

ECDSA Sign / Verify bytes using PK / SK

// Sign returns signature (slice of 65 bytes) of SK for passed message (slice of bytes),
// or error, if something went wrong:
signature, err := crypto.Sign(sk, message)

// Verify returns error message if PK is empty or
// passed wrong signature (slice of 65 bytes) for message (slice of bytes),
err := crypto.Verify(&sk.PublicKey, signature, message)  

RFC6979 Sign / Verify bytes using PK / SK

// Sign returns signature (slice of 64 bytes) of SK for passed message (slice of bytes),
// or error, if something went wrong:
signature, err := crypto.SignRFC6979(sk, message)

// Verify returns error message if PK is empty or
// passed wrong signature (slice of 64 bytes) for message (slice of bytes),
err := crypto.VerifyRFC6979(&sk.PublicKey, signature, message)  

WIF Encode / Decode private key (SK)

// WIFEncode encodes the given private key into a WIF string.
// if sk or sk.D is empty, returns error
wif, err := crypto.WIFEncode(sk)

// WIFDecode decoded the given WIF string into a private key.
// if something went wrong, returns error:
skFromWIF, err := crypto.WIFDecode(wif)

LoadPrivateKey

// Load private key from wif format
sk, err := crypto.LoadPrivateKey(wif_string)

// Load private key from hex string
sk, err := crypto.LoadPrivateKey(hex_string)

// Load private key from file
sk, err := crypto.LoadPrivateKey(file_path)