MCPcopy
hub / github.com/canopy-network/canopy / newClassGroup

Function newClassGroup

lib/crypto/classgroup.go:50–62  ·  view source on GitHub ↗

NewClassGroupFromABDiscriminant() calculates c using D = b^2 - 4ac and returns a class group object

(a, b, discriminant *big.Int)

Source from the content-addressed store, hash-verified

48
49// NewClassGroupFromABDiscriminant() calculates c using D = b^2 - 4ac and returns a class group object
50func newClassGroup(a, b, discriminant *big.Int) *ClassGroup {
51 // 4ac = b^2 - discriminant
52 fourAC := bip.New().Mul(b, b)
53 // subtract the discriminant
54 fourAC.Sub(fourAC, discriminant)
55 // c = floor(4ac / 4a)
56 fourA := bip.New()
57 c := floorDivision(fourAC, fourA.Mul(a, bigFour))
58 // cleanup big ints for memory efficiency
59 bip.Recycle(fourAC, fourA)
60 // return the class group
61 return NewClassGroup(a, b, c)
62}
63
64// Multiply performs multiplication of two elements from the class group
65// and returns the resulting class group element

Callers 4

TestClassDiscriminantFunction · 0.85
IdentityMethod · 0.85
DecodeMethod · 0.85
initVDFFunction · 0.85

Calls 4

floorDivisionFunction · 0.85
NewClassGroupFunction · 0.85
RecycleMethod · 0.80
NewMethod · 0.65

Tested by 1

TestClassDiscriminantFunction · 0.68