@@ -49,7 +49,6 @@ func init() {
49
49
50
50
// PrivateKey represents a private key in the HPPK protocol.
51
51
type PrivateKey struct {
52
- Prime * big.Int // Prime number used for cryptographic operations
53
52
R1 , S1 * big.Int // r1 and s1 are coprimes
54
53
R2 , S2 * big.Int // r2 and s2 are coprimes
55
54
F0 , F1 * big.Int // f(x) = f1x + f0
@@ -59,8 +58,9 @@ type PrivateKey struct {
59
58
60
59
// PublicKey represents a public key in the HPPK protocol.
61
60
type PublicKey struct {
62
- P []* big.Int // Coefficients of the polynomial P(x)
63
- Q []* big.Int // Coefficients of the polynomial Q(x)
61
+ Prime * big.Int // Prime number used for cryptographic operations
62
+ P []* big.Int // Coefficients of the polynomial P(x)
63
+ Q []* big.Int // Coefficients of the polynomial Q(x)
64
64
}
65
65
66
66
// Signature represents a digital signature in the HPPK protocol.
@@ -218,30 +218,25 @@ RETRY:
218
218
219
219
// Return the generated private key
220
220
return & PrivateKey {
221
- Prime : prime ,
222
- R1 : r1 ,
223
- S1 : s1 ,
224
- R2 : r2 ,
225
- S2 : s2 ,
226
- F0 : f0 ,
227
- F1 : f1 ,
228
- H0 : h0 ,
229
- H1 : h1 ,
221
+ R1 : r1 ,
222
+ S1 : s1 ,
223
+ R2 : r2 ,
224
+ S2 : s2 ,
225
+ F0 : f0 ,
226
+ F1 : f1 ,
227
+ H0 : h0 ,
228
+ H1 : h1 ,
230
229
PublicKey : PublicKey {
231
- P : P ,
232
- Q : Q ,
230
+ Prime : prime ,
231
+ P : P ,
232
+ Q : Q ,
233
233
},
234
234
}, nil
235
235
}
236
236
237
- // Encrypt encrypts a message using the given public key and custom prime number.
238
- func EncryptWithPrime (pub * PublicKey , msg []byte , prime * big.Int ) (kem * KEM , err error ) {
239
- return encrypt (pub , msg , prime )
240
- }
241
-
242
237
// Encrypt encrypts a message using the given public key and default prime number.
243
238
func Encrypt (pub * PublicKey , msg []byte ) (kem * KEM , err error ) {
244
- return encrypt (pub , msg , defaultPrime )
239
+ return encrypt (pub , msg , pub . Prime )
245
240
}
246
241
247
242
// encrypt encrypts a message using the given public key.
@@ -466,14 +461,9 @@ func (priv *PrivateKey) Order() int {
466
461
return len (priv .PublicKey .P ) - 2
467
462
}
468
463
469
- // VerifySignature verifies the signature of the message digest using the public key and given prime
470
- func VerifySignatureWithPrime (sig * Signature , digest []byte , pub * PublicKey , prime * big.Int ) bool {
471
- return verifySignature (sig , digest , pub , prime )
472
- }
473
-
474
464
// VerifySignature verifies the signature of the message digest using the public key and default prime
475
465
func VerifySignature (sig * Signature , digest []byte , pub * PublicKey ) bool {
476
- return verifySignature (sig , digest , pub , defaultPrime )
466
+ return verifySignature (sig , digest , pub , pub . Prime )
477
467
}
478
468
479
469
func verifySignature (sig * Signature , digest []byte , pub * PublicKey , prime * big.Int ) bool {
0 commit comments