Skip to content

Commit 8e38c26

Browse files
sorabotCre-eD
authored andcommitted
docs: name the two private key formats
The note told readers to trim a 128-character key without saying what the trailing half is or why it is there. Name the long form as the Iroha SDK format, state that a private key is 64 characters, and keep the trimming instruction for anyone holding the longer string. Signed-off-by: Dmitrii Creed <creeed22@gmail.com>
1 parent 8cfe6fa commit 8e38c26

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/overview/web-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Also see the following related tutorials:
9595

9696
::: tip NOTE
9797

98-
If the private key is displayed as a 128-character string, it is the private key followed by the public key. Whenever an API tutorial asks for a private key, use its first 64 characters.
98+
A private key is 64 characters long. In **Iroha SDK format** the public key is appended to it, making a 128-character string: the Iroha SDKs expect that longer form, every other library expects the 64-character key. If the key you copied is 128 characters, its first 64 characters are the private key.
9999

100100
:::
101101

src/tutorials-api/signing-user-email-addresses.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Any cryptographic library that provides Ed25519 and BLAKE2b-256 can produce it,
1414

1515
Sign with the **Authorization** key pair, not with the **Blockchain** one. Both key pairs are shown on the FIB Web App **Profile** screen. For details, see [Web App UI: 'Authorization' key pair](../overview/web-interface.md#akp).
1616

17-
If the private key on that screen is 128 characters long, it is the private key followed by the public key. Use its first 64 characters as the private key.
17+
A private key is 64 characters long. In **Iroha SDK format** the public key is appended to it, making a 128-character string: the Iroha SDKs expect that longer form, every other library expects the 64-character key. If the key you copied is 128 characters, its first 64 characters are the private key.
1818

1919
A signature made with the wrong key pair is rejected with a `422` response.
2020

@@ -34,7 +34,7 @@ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
3434

3535

3636
def sign_email(email: str, auth_private_key_hex: str) -> str:
37-
# A 128-character key is the private key followed by the public key.
37+
# In Iroha SDK format the key is 128 characters: private key then public key.
3838
key = Ed25519PrivateKey.from_private_bytes(bytes.fromhex(auth_private_key_hex[:64]))
3939
digest = hashlib.blake2b(email.encode("utf-8"), digest_size=32).digest()
4040
return key.sign(digest).hex()
@@ -57,8 +57,8 @@ const PKCS8_ED25519_PREFIX = '302e020100300506032b657004220420'
5757

5858
/**
5959
* @param {string} email
60-
* @param {string} authPrivateKeyHex - a 128-character key is the private key
61-
* followed by the public key
60+
* @param {string} authPrivateKeyHex - in Iroha SDK format the key is 128
61+
* characters: private key then public key
6262
* @returns {string} - email signature hex
6363
*/
6464
function signEmail(email, authPrivateKeyHex) {

0 commit comments

Comments
 (0)