Git Product home page Git Product logo

xuperchain / crypto Goto Github PK

View Code? Open in Web Editor NEW
62.0 5.0 27.0 1.42 MB

This project is the crypto library for XuperChain. Ring signature, multi signature, schnorr signature, secret share, hierarchical deterministic encryption, threshold signature scheme(tss schnorr) , bls signature have been supported.目前开源部分已经支持了Xuper统一超级签名算法、Schnorr签名,环签名、多重签名,tss(schnorr)门限签名,BLS签名等多种签名算法。也支持了秘密分享、分层确定性加解密等多种密码学能力。

License: Apache License 2.0

Makefile 0.06% Shell 0.06% Go 99.89%
threshold-signature schnorr-signature ring-signature multi-signature

crypto's Introduction

XuperChain Crypto

This project is the crypto library for XuperChain.

本项目是超级链相关的密码库模块。目前开源部分已经支持了Xuper统一超级签名算法、Schnorr签名,环签名、多重签名等多种签名算法。也支持了秘密分享、分层确定性加解密等多种密码学能力。

NIST系列算法请引用: "github.com/xuperchain/crypto/client/service/xchain"

详细函数说明请参考该类的函数注释

使用例子:

import (
	"log"

	"github.com/xuperchain/crypto/client/service/xchain"
	"github.com/xuperchain/crypto/core/account"
	"github.com/xuperchain/crypto/core/hdwallet/rand"
)

xcc := new(xchain.XchainCryptoClient)

ecdsaAccount, err := xcc.CreateNewAccountWithMnemonic(rand.SimplifiedChinese, account.StrengthHard)
if err != nil {
	log.Printf("CreateNewAccountWithMnemonic failed and err is: %v", err)
	return
}

log.Printf("mnemonic is %v, jsonPrivateKey is %v, jsonPublicKey is %v and address is %v", ecdsaAccount.Mnemonic, ecdsaAccount.JsonPrivateKey, ecdsaAccount.JsonPublicKey, ecdsaAccount.Address)

国密系列算法请引用: "github.com/xuperchain/crypto/client/service/gm"

详细函数说明请参考该类的函数注释

使用例子:

import (
	"log"

	"github.com/xuperchain/crypto/client/service/gm"
	"github.com/xuperchain/crypto/gm/account"
	"github.com/xuperchain/crypto/gm/hdwallet/rand"
)

gcc := new(gm.GmCryptoClient)

ecdsaAccount, err := gcc.CreateNewAccountWithMnemonic(rand.SimplifiedChinese, account.StrengthHard)
if err != nil {
	log.Printf("CreateNewAccountWithMnemonic failed and err is: %v", err)
	return
}
log.Printf("mnemonic is %v, jsonPrivateKey is %v, jsonPublicKey is %v and address is %v", ecdsaAccount.Mnemonic, ecdsaAccount.JsonPrivateKey, ecdsaAccount.JsonPublicKey, ecdsaAccount.Address)

crypto's People

Contributors

boyaoding avatar hawkjing avatar hongyanwang avatar stone-ch avatar zhangpeiqian2010 avatar zhugelianglongming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

crypto's Issues

Security issue

We would like to report a vulnerability in the crypto library.
Since there is no security policy mentioned for the repository, can you please forward any contact that we can use to disclose the vulnerability.
Not sure if the disclosure should be done straight in a public issue.

cryptoClient.SecretSplit函数secret长度超过32时异常

package main

import (
	"fmt"
	"math/big"
	"testing"

	"github.com/xuperchain/xuper-sdk-go/v2/crypto"
)

func TestSecretSplit(t *testing.T) {

	secret := []byte("111111111111111111111111111111111")
	fmt.Println(len(secret))
	cryptoClient := crypto.GetCryptoClient()

	// bug : 当参数 secret 长度超过32时,无法正常恢复
	m, _ := cryptoClient.SecretSplit(5, 3, secret)

	shares := make(map[int]*big.Int)
	shares[5] = m[5]
	shares[4] = m[4]
	shares[3] = m[3]
	b2, _ := cryptoClient.SecretRetrieve(shares)

	fmt.Println(string(b2))

}

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.