mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 10:27:26 +08:00
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete * 2.1.0 main node rollup
41 lines
818 B
Go
41 lines
818 B
Go
//
|
|
// mpint.go
|
|
//
|
|
// Copyright (c) 2019 Markku Rossi
|
|
//
|
|
// All rights reserved.
|
|
//
|
|
|
|
package mpint
|
|
|
|
import (
|
|
"math/big"
|
|
)
|
|
|
|
// FromBytes creates a big.Int from the data.
|
|
func FromBytes(data []byte) *big.Int {
|
|
return big.NewInt(0).SetBytes(data)
|
|
}
|
|
|
|
// Add adds two big.Int numbers and returns the result as a new
|
|
// big.Int.
|
|
func Add(a, b *big.Int) *big.Int {
|
|
return big.NewInt(0).Add(a, b)
|
|
}
|
|
|
|
// Sub subtracts two big.Int numbers and returns the result as a new
|
|
// big.Int.
|
|
func Sub(a, b *big.Int) *big.Int {
|
|
return big.NewInt(0).Sub(a, b)
|
|
}
|
|
|
|
// Exp computes x^y MOD m and returns the result as a new big.Int.
|
|
func Exp(x, y, m *big.Int) *big.Int {
|
|
return big.NewInt(0).Exp(x, y, m)
|
|
}
|
|
|
|
// Mod computes x%y and returns the result as a new big.Int.
|
|
func Mod(x, y *big.Int) *big.Int {
|
|
return big.NewInt(0).Mod(x, y)
|
|
}
|