-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bip-324: fix FSChaCha20 type error #1478
base: master
Are you sure you want to change the base?
Conversation
The FSChaCha20 class, as written in the BIP's pseudocode, doesn't have an encrypt() method (even though the equivalent class in the `bip-0324/reference.py` does), so use crypt() to be clear that we're not using FSChaCha20Poly1305 for `peer.send_L`.
(Probably worth tagging @real-or-random @jonasschnelli @sipa) |
3390236
to
f1cd630
Compare
For some reason, the fragments `b''` and `__init__` don't display properly in Github's mediawiki format, so special-case those.
While in the neighborhood, I've added Python syntax highlighting where possible. Apparently Python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It seems people actually read this. :)
Sad that GitHub rendering is that broken...
assert len(contents) <= 2**24 - 1 | ||
header = (ignore << IGNORE_BIT_POS).to_bytes(HEADER_LEN, 'little') | ||
plaintext = header + contents | ||
aead_ciphertext = peer.send_P.encrypt(aad, plaintext) | ||
enc_contents_len = peer.send_L.encrypt(len(contents).to_bytes(LENGTH_FIELD_LEN, 'little')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm., I think I'd prefer to add encrypt
and decrypt
methods to the class.
CHACHA20POLY1305_EXPANSION = 16 | ||
|
||
def v2_receive_packet(peer, aad=b'', skip_decoy=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Did you change these intentionally? Now we have both '
and "
in the source, which is also not very consistent.
cc @dhruv |
@jamesob Rebase? |
Are you still working on this, @jamesob? |
The FSChaCha20 class, as written in the BIP's pseudocode, doesn't have an encrypt() method (even though the equivalent class in
bip-0324/reference.py
does), so use crypt() to be clear that we're not using FSChaCha20Poly1305 forpeer.send_L
.