Giter VIP home page Giter VIP logo

frostfs-crypto's Introduction

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)

frostfs-crypto's People

Contributors

alexvanin avatar im-kulikov avatar fyrchik avatar

Stargazers

Snegurochka avatar  avatar Anton Nikiforov avatar  avatar  avatar Anatoly Bogatyrev avatar  avatar  avatar Andrey Lesnykh avatar  avatar Vladimir Avdeev avatar Dmitri Usov avatar Vlad K. avatar  avatar  avatar Aleksey Chetaev avatar  avatar Vladimir avatar Stanislav Bogatyrev avatar

Forkers

realloc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.