From 7040a2024795a7e3758c7ab604ab440652c9772f Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Tue, 7 May 2024 19:38:51 +0200 Subject: [PATCH] doc: fix sage code for deriving alternative generator H The expression `G.decode('hex')` fails with the following error message on Sage 9.5: AttributeError: 'str' object has no attribute 'decode' Fix that by converting the hex-string to bytes using `bytes.fromhex`. --- src/modules/generator/main_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/generator/main_impl.h b/src/modules/generator/main_impl.h index 28536694..f1cd0779 100644 --- a/src/modules/generator/main_impl.h +++ b/src/modules/generator/main_impl.h @@ -24,7 +24,7 @@ import hashlib F = FiniteField (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F) G = '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8' - H = EllipticCurve ([F (0), F (7)]).lift_x(F(int(hashlib.sha256(G.decode('hex')).hexdigest(),16))) + H = EllipticCurve ([F (0), F (7)]).lift_x(F(int(hashlib.sha256(bytes.fromhex(G)).hexdigest(),16))) print('%x %x' % H.xy()) */ static const secp256k1_generator secp256k1_generator_h_internal = {{