Files
d70b26685f Ecdsa proof session byte (#256)
* Add modProof in ECDSA-keygen

* Reduce test param to reduce github workflow load

* Add test fixtures

* Fix EDDSA keygen example

* Restore test fixtures

* Compress modproof

* use warning instead of fatal in logger to prevent panic

* Add more checks in range proof

* Regenerate preparams for older version

* Reset test params and regenerate fixtures

* Update ecdsa-resharing with Paillier key proofs

* Add a switch to optional turn off Pai key proofs

* Update README for caution of preparams updated

* add: ecdsa proof session byte

---------

Co-authored-by: ycen <[email protected]>
Co-authored-by: ZhAnGeek <[email protected]>
2023-08-23 11:12:34 +08:00

65 lines
1.5 KiB
Go

// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
package common
import (
"math/big"
)
func BigIntsToBytes(bigInts []*big.Int) [][]byte {
bzs := make([][]byte, len(bigInts))
for i := range bzs {
if bigInts[i] == nil {
continue
}
bzs[i] = bigInts[i].Bytes()
}
return bzs
}
func MultiBytesToBigInts(bytes [][]byte) []*big.Int {
ints := make([]*big.Int, len(bytes))
for i := range ints {
ints[i] = new(big.Int).SetBytes(bytes[i])
}
return ints
}
// Returns true when the byte slice is non-nil and non-empty
func NonEmptyBytes(bz []byte) bool {
return bz != nil && 0 < len(bz)
}
// Returns true when all of the slices in the multi-dimensional byte slice are non-nil and non-empty
func NonEmptyMultiBytes(bzs [][]byte, expectLen ...int) bool {
if len(bzs) == 0 {
return false
}
// variadic (optional) arg test
if 0 < len(expectLen) && expectLen[0] != len(bzs) {
return false
}
for _, bz := range bzs {
if !NonEmptyBytes(bz) {
return false
}
}
return true
}
// PadToLengthBytesInPlace pad {0, ...} to the front of src if len(src) < length
// output length is equal to the parameter length
func PadToLengthBytesInPlace(src []byte, length int) []byte {
oriLen := len(src)
if oriLen < length {
for i := 0; i < length-oriLen; i++ {
src = append([]byte{0}, src...)
}
}
return src
}