mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-21 05:53:12 +00:00
more bytes clarification
This commit is contained in:
parent
238f604bf5
commit
f52a6ce9bb
@ -21,20 +21,20 @@ def sign_to_foolscap(announcement, signing_key):
|
|||||||
e.g. :func:`allmydata.crypto.ed25519.signing_keypair_from_string`
|
e.g. :func:`allmydata.crypto.ed25519.signing_keypair_from_string`
|
||||||
|
|
||||||
:returns: 3-tuple of (msg, sig, vk) where msg is a UTF8 JSON
|
:returns: 3-tuple of (msg, sig, vk) where msg is a UTF8 JSON
|
||||||
serialization of the `announcement`, sig is bytes (a signature of
|
serialization of the `announcement` (bytes), sig is bytes (a
|
||||||
msg) and vk is the verifying key
|
signature of msg) and vk is the verifying key bytes
|
||||||
"""
|
"""
|
||||||
# return (bytes, sig-str, pubkey-str). A future HTTP-based serialization
|
# return (bytes, sig-str, pubkey-str). A future HTTP-based serialization
|
||||||
# will use JSON({msg:b64(JSON(msg).utf8), sig:v0-b64(sig),
|
# will use JSON({msg:b64(JSON(msg).utf8), sig:v0-b64(sig),
|
||||||
# pubkey:v0-b64(pubkey)}) .
|
# pubkey:v0-b64(pubkey)}) .
|
||||||
msg = json.dumps(announcement).encode("utf-8")
|
msg = json.dumps(announcement).encode("utf-8")
|
||||||
sig = "v0-" + base32.b2a(
|
sig = b"v0-" + base32.b2a(
|
||||||
ed25519.sign_data(signing_key, msg)
|
ed25519.sign_data(signing_key, msg)
|
||||||
)
|
)
|
||||||
verifying_key_bytes = ed25519.bytes_from_verifying_key(
|
verifying_key_bytes = ed25519.bytes_from_verifying_key(
|
||||||
ed25519.verifying_key_from_signing_key(signing_key)
|
ed25519.verifying_key_from_signing_key(signing_key)
|
||||||
)
|
)
|
||||||
ann_t = (msg, sig, "v0-" + base32.b2a(verifying_key_bytes))
|
ann_t = (msg, sig, b"v0-" + base32.b2a(verifying_key_bytes))
|
||||||
return ann_t
|
return ann_t
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user