From 43fbddf016f94f4ba006d82c9a67dca61b5852a1 Mon Sep 17 00:00:00 2001 From: Gab <24553253+gabrix73@users.noreply.github.com> Date: Fri, 14 Aug 2026 20:39:22 +0200 Subject: Complete Nym and YAMN transport integration --- yamn/encoder/encoder.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'yamn/encoder/encoder.go') diff --git a/yamn/encoder/encoder.go b/yamn/encoder/encoder.go index 5eacdf3..3b595b1 100644 --- a/yamn/encoder/encoder.go +++ b/yamn/encoder/encoder.go @@ -304,19 +304,20 @@ func slotData(kind byte, packetID, aesKey, info, tag []byte) []byte { } func encryptedHeader(key remailerKey, data []byte) []byte { - var recipient, sender [32]byte + var recipient [32]byte copy(recipient[:], key.publicKey) - if _, err := io.ReadFull(rand.Reader, sender[:]); err != nil { + senderPublic, senderSecret, err := box.GenerateKey(rand.Reader) + if err != nil { panic(err) } var nonce [24]byte if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil { panic(err) } - sealed := box.Seal(nil, data, &nonce, &recipient, &sender) + sealed := box.Seal(nil, data, &nonce, &recipient, senderSecret) b := make([]byte, headerBytes) copy(b, key.keyID) - copy(b[16:], sender[:]) + copy(b[16:], senderPublic[:]) copy(b[48:], nonce[:]) copy(b[72:], sealed) return b @@ -370,7 +371,7 @@ func deterministic(p []byte, keys, ivs [][]byte, chainLen, hop int) { for slot := top; slot <= bottom; slot++ { fake := make([]byte, headerBytes) use := bottom - for i := bottom - slot + hop; i >= 0; i-- { + for i := bottom - slot + hop; i >= hop; i-- { copy(fake, aesCTR(fake, keys[i], seqIV(ivs[i], use))) use-- } -- cgit v1.2.3