Documentation ¶
Index ¶
- Variables
- type GroupParameters
- type IntegerElement
- type IntegerGroup
- func (i IntegerGroup) Add(a, b group.Element) group.Element
- func (i IntegerGroup) BasePointMult(s *big.Int) group.Element
- func (i IntegerGroup) ConstM() group.Element
- func (i IntegerGroup) ConstN() group.Element
- func (i IntegerGroup) ConstS() group.Element
- func (i IntegerGroup) ElementFromBytes(b []byte) (group.Element, error)
- func (i IntegerGroup) ElementSize() int
- func (i IntegerGroup) ElementToBytes(x group.Element) []byte
- func (i IntegerGroup) Order() *big.Int
- func (i IntegerGroup) PasswordToScalar(pw []byte) *big.Int
- func (i IntegerGroup) RandomScalar() (*big.Int, error)
- func (i IntegerGroup) ScalarMult(e group.Element, s *big.Int) group.Element
Constants ¶
This section is empty.
Variables ¶
var ( //I1024 is 1024 bit group. I1024 = new1024() // I2048 is 2048 bit group. I2048 = new2048() // I3072 is 3072 bit group I3072 = new3072() // Zero is identity element of group Zero = big.NewInt(1) )
J-PAKE demo code from java http://haofeng66.googlepages.com/JPAKEDemo.java., recommended these 2048 and 3072 bit groups from this NIST document: http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/DSA2_All.pdf
Functions ¶
This section is empty.
Types ¶
type GroupParameters ¶
type GroupParameters struct {
// contains filtered or unexported fields
}
GroupParameters defines a cyclic abelian group
type IntegerElement ¶
type IntegerElement struct {
// contains filtered or unexported fields
}
IntegerElement represents integer of specific multiplicative group.
func (IntegerElement) Add ¶
func (i IntegerElement) Add(other group.Element) group.Element
Add is actually multiplication mod `p` where `p` is order of the multiplicative group
func (IntegerElement) Negate ¶
func (i IntegerElement) Negate() group.Element
Negate return negated representation of given element.
func (IntegerElement) ScalarMult ¶
func (i IntegerElement) ScalarMult(s *big.Int) group.Element
ScalarMult for multiplicative group is g^s mod p where `g` is group generator and p is order of the group
type IntegerGroup ¶
type IntegerGroup struct {
// contains filtered or unexported fields
}
IntegerGroup defines multiplicative group on integer
func (IntegerGroup) Add ¶
func (i IntegerGroup) Add(a, b group.Element) group.Element
Add adds 2 group element. Since this is multiplicative add operation is actually multiplication. Note: Caller should take care that other element is of same group function itself does not do this check as its written for implementing group interface of gospake2
func (IntegerGroup) BasePointMult ¶
func (i IntegerGroup) BasePointMult(s *big.Int) group.Element
BasePointMult multiplies given scalar to generator of the multiplicative group.In this case the result is g^x mod p where g is generator of the integer group and p is prime order of the group.
func (IntegerGroup) ConstM ¶
func (i IntegerGroup) ConstM() group.Element
ConstM returns the element M from the integer group i used in SPAKE2 caclulation
func (IntegerGroup) ConstN ¶
func (i IntegerGroup) ConstN() group.Element
ConstN returns the element N from integer group i used in SPAKE2 calculation
func (IntegerGroup) ConstS ¶
func (i IntegerGroup) ConstS() group.Element
ConstS returns the element S from integer group i used in SPAKE2 symmetric mode caclulation
func (IntegerGroup) ElementFromBytes ¶
func (i IntegerGroup) ElementFromBytes(b []byte) (group.Element, error)
ElementFromBytes converts given byte slice into element of integer group i. In case element is either identity or does not belong to zero error is returned. Resulting element should satisfy condition e^q mod p where q is order of subgroup and p is the prime number which is order of group
func (IntegerGroup) ElementSize ¶
func (i IntegerGroup) ElementSize() int
ElementSize returns the group element size in bytes
func (IntegerGroup) ElementToBytes ¶
func (i IntegerGroup) ElementToBytes(x group.Element) []byte
ElementToBytes converts given big integer element of the group to bytes
func (IntegerGroup) Order ¶
func (i IntegerGroup) Order() *big.Int
Order returns the subgroup order for the integer group
func (IntegerGroup) PasswordToScalar ¶
func (i IntegerGroup) PasswordToScalar(pw []byte) *big.Int
PasswordToScalar expands given password bytes into a integer belonging to the group
func (IntegerGroup) RandomScalar ¶
func (i IntegerGroup) RandomScalar() (*big.Int, error)
RandomScalar returns a random scalar which is in the group
func (IntegerGroup) ScalarMult ¶
ScalarMult is repeatedly multiplying group element g with scalar x which is equivalaent to element^x mod p in multiplicative group of prime order p