Git Product home page Git Product logo

go-slip10's Introduction

Ed25519 private key derivation from master private key

Golang SLIP-0010 implementation(ed25519 only) according to the https://github.com/satoshilabs/slips/blob/master/slip-0010.md

Example

    package main

    import (
    	"encoding/hex"
    	"fmt"

    	slip10 "github.com/anytypeio/go-slip10"
    )

    func main() {
    	seed, err := hex.DecodeString("000102030405060708090a0b0c0d0e0f")
    	if err != nil {
    		panic(err)
    	}

    	// example vector 1: https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-ed25519
    	node, err := slip10.DeriveForPath("m/0'/1'", seed)
    	if err != nil {
    		panic(err)
    	}

    	pub, priv, err := node.Keypair()
    	if err != nil {
    		panic(err)
    	}

    	// prints b1d0bad404bf35da785a64ca1ac54b2617211d2777696fbffaf208f746ae84f2
    	fmt.Printf("%x\n", priv)

    	// prints 1932a5270f335bed617d5b935c80aedb1a35bd9fc1e31acafd5372c30f5c1187
    	// You can notice that example at https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-ed25519
    	// adds 0x00 prefix for the public key. Because we are using native crypto/ed25519 for the keypair we won't do this for the Keypair() method
    	fmt.Printf("%x\n", pub)

    	// but you can use node.PublicKeyWithPrefix() to get the public key with prefix
    	pubK, err := node.PublicKeyWithPrefix()
    	if err != nil {
    		panic(err)
    	}

    	// prints 001932a5270f335bed617d5b935c80aedb1a35bd9fc1e31acafd5372c30f5c1187
    	fmt.Printf("%x\n", pubK)
    }

Licensing

The code in this project is licensed under the MIT License

go-slip10's People

Contributors

requilence avatar

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.