forked from bnb-chain/tss-lib
/
utils.go
27 lines (23 loc) · 941 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// 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 crypto
import (
"fmt"
"math/big"
"github.com/Aasifj2/tss-lib/common"
)
func GenerateNTildei(safePrimes [2]*big.Int) (NTildei, h1i, h2i *big.Int, err error) {
if safePrimes[0] == nil || safePrimes[1] == nil {
return nil, nil, nil, fmt.Errorf("GenerateNTildei: needs two primes, got %v", safePrimes)
}
if !safePrimes[0].ProbablyPrime(30) || !safePrimes[1].ProbablyPrime(30) {
return nil, nil, nil, fmt.Errorf("GenerateNTildei: expected two primes")
}
NTildei = new(big.Int).Mul(safePrimes[0], safePrimes[1])
h1 := common.GetRandomGeneratorOfTheQuadraticResidue(NTildei)
h2 := common.GetRandomGeneratorOfTheQuadraticResidue(NTildei)
return NTildei, h1, h2, nil
}