@@ -304,10 +304,10 @@ func newXKHandshakeState(initiator bool, prologue []byte,
304
304
// EphemeralGenerator is a functional option that allows callers to substitute
305
305
// a custom function for use when generating ephemeral keys for ActOne or
306
306
// ActTwo. The function closure return by this function can be passed into
307
- // NewNoiseMachine as a function option parameter.
307
+ // NewNoiseMachine(XK or XX) as a function option parameter.
308
308
func EphemeralGenerator (gen func () (* koblitz.PrivateKey , error )) func (* Machine ) {
309
309
return func (m * Machine ) {
310
- m .ephemeralGen = gen
310
+ m .EphemeralGen = gen
311
311
}
312
312
}
313
313
@@ -353,7 +353,8 @@ type Machine struct {
353
353
sendCipher cipherState
354
354
recvCipher cipherState
355
355
356
- ephemeralGen func () (* koblitz.PrivateKey , error )
356
+ EphemeralGen func () (* koblitz.PrivateKey , error )
357
+ // this is exported in order for noise_test to define a static ephemeral pubkey
357
358
358
359
handshakeState
359
360
@@ -372,7 +373,7 @@ type Machine struct {
372
373
nextCipherText [math .MaxUint16 + macSize ]byte
373
374
}
374
375
375
- // NewNoiseMachine creates a new instance of the lndc state-machine. If
376
+ // NewNoiseXKMachine creates a new instance of the lndc state-machine. If
376
377
// the responder (listener) is creating the object, then the remotePub should
377
378
// be nil. The handshake state within lndc is initialized using the ascii
378
379
// string "lightning" as the prologue. The last parameter is a set of variadic
@@ -387,7 +388,7 @@ func NewNoiseXKMachine(initiator bool, localStatic *koblitz.PrivateKey,
387
388
m := & Machine {handshakeState : handshake }
388
389
// With the initial base machine created, we'll assign our default
389
390
// version of the ephemeral key generator.
390
- m .ephemeralGen = func () (* koblitz.PrivateKey , error ) {
391
+ m .EphemeralGen = func () (* koblitz.PrivateKey , error ) {
391
392
return koblitz .NewPrivateKey (koblitz .S256 ())
392
393
}
393
394
@@ -402,7 +403,7 @@ func NewNoiseXXMachine(initiator bool, localStatic *koblitz.PrivateKey) *Machine
402
403
403
404
// With the initial base machine created, we'll assign our default
404
405
// version of the ephemeral key generator.
405
- m .ephemeralGen = func () (* koblitz.PrivateKey , error ) {
406
+ m .EphemeralGen = func () (* koblitz.PrivateKey , error ) {
406
407
return koblitz .NewPrivateKey (koblitz .S256 ())
407
408
}
408
409
@@ -475,7 +476,7 @@ func (b *Machine) GenActOne(remotePK [33]byte) ([]byte, error) {
475
476
var err error
476
477
actOne := make ([]byte , ActOneSize )
477
478
// Generate e
478
- b .localEphemeral , err = b .ephemeralGen ()
479
+ b .localEphemeral , err = b .EphemeralGen ()
479
480
if err != nil {
480
481
return actOne , err
481
482
}
@@ -544,7 +545,7 @@ func (b *Machine) GenActTwo(HandshakeVersion byte) ([]byte, error) {
544
545
var err error
545
546
actTwo := make ([]byte , ActTwoSize )
546
547
// e
547
- b .localEphemeral , err = b .ephemeralGen ()
548
+ b .localEphemeral , err = b .EphemeralGen ()
548
549
if err != nil {
549
550
return actTwo , err
550
551
}
0 commit comments