Exemple #1
0
// Create a new Secret for the Ed25519 curve.
func (c *Curve) Secret() abstract.Secret {
	//	if c.FullGroup {
	//		return nist.NewInt(0, fullOrder)
	//	} else {
	return nist.NewInt(0, &primeOrder.V)
	//	}
}
Exemple #2
0
/* Creates a new insurance request message
 *
 * Arguments:
 *	s  = the shared secret to give to the insurer.
 *      pc = the public polynomial to check the share against.
 *
 * Returns:
 *	A new insurance request message.
 */
func (msg *RequestInsuranceMessage) createMessage(p abstract.Point, shareNum int,
	s abstract.Secret, pc *poly.PubPoly) *RequestInsuranceMessage {
	msg.PubKey = p
	msg.ShareNumber = nist.NewInt(int64(shareNum), big.NewInt(int64(math.MaxInt64)))
	msg.Share = s
	msg.PubCommit = pc
	return msg
}
Exemple #3
0
// Decodes a message received.
// NOTE: In order to be encoded properly, public polynomials need to be
// initialized with the right group and minimum number of shares.
func (msg *RequestInsuranceMessage) UnmarshalBinary(data []byte) (*RequestInsuranceMessage, error) {
	msg.PubCommit = new(poly.PubPoly)
	msg.PubCommit.Init(INSURE_GROUP, TSHARES, nil)
	msg.PubKey = KEY_SUITE.Point()
	msg.Share = INSURE_GROUP.Secret().Pick(random.Stream)
	msg.ShareNumber = nist.NewInt(int64(0), big.NewInt(int64(math.MaxInt64)))
	b := bytes.NewBuffer(data)
	err := abstract.Read(b, msg, INSURE_GROUP)
	if err != nil {
		panic(err)
	}
	return msg, err
	//	return 	msg, protobuf.Decode(data, msg)

}
Exemple #4
0
// Create a new ModInt representing a coordinate on this curve,
// with a given int64 integer value for constant-initialization convenience.
func (P *basicPoint) coord(v int64) *nist.Int {
	return nist.NewInt(v, &P.c.P)
}
Exemple #5
0
// Create a new Secret for this curve.
func (c *curve) Secret() abstract.Secret {
	return nist.NewInt(0, &c.order.V)
}
Exemple #6
0
	"crypto/cipher"
	"crypto/sha256"
	"encoding/hex"
	"github.com/dedis/crypto/abstract"
	"github.com/dedis/crypto/group"
	"github.com/dedis/crypto/nist"
	"github.com/dedis/crypto/random"
	"github.com/dedis/crypto/sha3"
	"math/big"
)

// prime order of base point = 2^252 + 27742317777372353535851937790883648493
var primeOrder, _ = new(nist.Int).SetString("7237005577332262213973186563042994240857116359379907606001950938285454250989", "", 10)

// curve's cofactor
var cofactor = nist.NewInt(8, &primeOrder.V)

var nullPoint = new(point).Null()

type point struct {
	p C.ge_p3
}

type curve struct {
}

// Convert little-endian byte slice to hex string
func tohex(s []byte) string {
	b := make([]byte, len(s))
	for i := range b { // byte-swap to big-endian for display
		b[i] = s[31-i]