Skip to content

Commit 2d84c2f

Browse files
committed
Work toward correct operation of <generator>.send( ... )
1 parent 5b9f90a commit 2d84c2f

File tree

8 files changed

+672
-15
lines changed

8 files changed

+672
-15
lines changed

GNUmakefile

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test:
7777
$(PY3TEST)
7878

7979
analyze:
80-
flake8 -j 1 --max-line-length=250 \
80+
flake8 --color never -j 1 --max-line-length=250 \
8181
--ignore=W503,E201,E202,E203,E127,E221,E223,E226,E231,E241,E242,E251,E265,E272,E274 \
8282
slip39
8383

@@ -127,6 +127,63 @@ slip39/layout/COVER.txt:
127127
# Any build dependencies that are dynamically generated, and may need updating from time to time
128128
deps: $(TXT) slip39/gui/SLIP-39.txt slip39/layout/COVER.txt
129129

130+
131+
#
132+
# Agent Keypairs, Product Licences
133+
#
134+
135+
GLOBAL_OPTIONS = -vv
136+
137+
CREDENTIALS = $(abspath $(HOME)/.crypto-licensing )
138+
139+
export CRYPTO_LIC_PASSWORD
140+
export CRYPTO_LIC_USERNAME
141+
142+
.PHONY: slip-39 perry-kundert
143+
products: slip-39 \
144+
perry-kundert \
145+
146+
slip-39:
147+
148+
perry-kundert: [email protected]
149+
perry-kundert: CRYPTO_LIC_PASSWORD=password
150+
perry-kundert: slip39/invoice/payments_test/perry-kundert.crypto-license
151+
perry-kundert: GRANTS="{\"crypto-licensing-server\": {\
152+
\"override\": { \
153+
\"rate\": \"0.1%\", \
154+
\"crypto\": { \
155+
\"ETH\": \"0xe4909b66FD66DA7d86114695A1256418580C8767\", \
156+
\"BTC\": \"bc1qygm3dlynmjxuflghr0hmq6r7wmff2jd5gtgz0q\" \
157+
}\
158+
}\
159+
}}"
160+
161+
162+
163+
# Create .crypto-keypair from seed; note: if the make rule fails, intermediate files are deleted.
164+
# We expect any password to be transmitted in CRYPTO_LIC_PASSWORD env. var.
165+
%.crypto-keypair: %.crypto-seed
166+
$(PY3) -m crypto_licensing $(GLOBAL_OPTIONS) \
167+
--extra $(dir $(basename $@ )) \
168+
--name $(notdir $(basename $@ )) \
169+
--reverse-save \
170+
registered \
171+
--username $(USERNAME) \
172+
--seed $$( cat $< )
173+
174+
# Create .crypto-license, signed by .crypto-keypair
175+
%.crypto-license : %.crypto-keypair
176+
$(PY3) -m crypto_licensing $(GLOBAL_OPTIONS) \
177+
--extra $(dir $(basename $@ )) \
178+
--name $(notdir $(basename $@ )) \
179+
--reverse-save \
180+
license \
181+
--username $(USERNAME) --no-registering \
182+
--client $(CLIENT) --client-pubkey $(CLIENT_PUBKEY) \
183+
--grant $(GRANTS) \
184+
--author $(AUTHOR) --domain $(DOMAIN) --product $(PRODUCT) $(LICENSE_OPTIONS)
185+
186+
130187
#
131188
# VirtualEnv build, install and activate
132189
#

requirements-invoice.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ dkimpy[ed25519] >=1.0.5,<2
1010
# These versions are very brittle; must be upgraded in lock-step (see web3.py/setup.py)
1111
web3[tester] ==6.0.0b9
1212
eth-tester[py-evm] ==v0.8.0-b.3
13+
14+
# Until ethpm upgrade to avoid dependency
15+
ipfshttpclient ; python_version >= "3.11"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
base58 >=2.0.1,<3
22
chacha20poly1305 >=0.0.3
33
click >=8.1.3,<9
4-
crypto-licensing >=3.0.4,<4
4+
crypto-licensing >=3.2.0,<4
55
cx_Freeze >=6.12 ; sys_platform == "win32"
66
fpdf2 >=2.5.7,<3
77
hdwallet >=2.2.1,<3

slip39/invoice/artifact_test.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def items( n, most=None, seen=None ):
568568
paths = f"../-{desired - 1}"
569569

570570
invoices_to_write = [
571-
[
571+
(
572572
# - No obvious route between line-item currencies, and invoice currency:
573573
#
574574
# Only XRP LineItems, want USDC in 'currencies' payable (as well as 'BTC', 'ETH' and
@@ -577,25 +577,31 @@ def items( n, most=None, seen=None ):
577577
# ('BTC',<something>).
578578
Invoice(
579579
items( random.randint( 1, 100 ), most=1, seen=set( ('XRP', ) )),
580-
accounts = [
581-
account( SEED_ZOOS, crypto='Ethereum' ),
582-
account( SEED_ZOOS, crypto='Bitcoin' ),
583-
account( SEED_ZOOS, crypto='Ripple' ),
584-
],
580+
accounts = a,
585581
currencies = ['USDC'],
586582
conversions = dict( conversions ) # | {('BTC','ETH'): None}, # now automatic
587583
)
588-
],
589-
[
584+
for a in [
585+
[
586+
account( SEED_ZOOS, crypto='Ethereum' ),
587+
account( SEED_ZOOS, crypto='Bitcoin' ),
588+
account( SEED_ZOOS, crypto='Ripple' ),
589+
]
590+
]
591+
),
592+
(
590593
# - Only ETH. No conversions required.
591594
Invoice(
592595
items( random.randint( 1, 100 ), most=1, seen=set( ('ETH', ) )),
593-
accounts = [
594-
account( SEED_ZOOS, crypto='Ethereum' ),
595-
],
596+
accounts = a,
596597
currencies = ['ETH'],
597598
)
598-
],
599+
for a in [
600+
[
601+
account( SEED_ZOOS, crypto='Ethereum' ),
602+
]
603+
]
604+
),
599605
(
600606
# - Random combinations of LineItem / Invoice currencies
601607
#

slip39/invoice/multipayout_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,11 @@ def test_multipayout_api( testnet, provider, chain_id, src, src_prvkey, destinat
963963
# OK, we can now sign the 128-bit UUIDv4 bytes w/ the agent keypair.sk (signing key). The first
964964
# 64 bytes of the signed document is the signature.
965965
machine_signed = ed25519.crypto_sign( machine.bytes, keypair.sk )
966-
print( f"{licensing.into_b64( keypair.vk )}: machine UUID signed: {machine_signed.hex()}" )
966+
print( f"{licensing.into_b64( keypair.vk )}: machine UUID sign: {machine_signed.hex()}" )
967+
machine_sig = machine_signed[:64]
968+
print( f"{licensing.into_b64( keypair.vk )}: machine UUID signature: {licensing.into_b64( machine_sig )}" )
969+
assert ed25519.crypto_sign_open( machine_sig + machine.bytes, keypair.vk ) == machine.bytes, \
970+
f"Failed to verify machine ID {machine.bytes.hex()} w/ signature {licensing.into_b64( machine_sig )}"
967971

968972
# A 512-bit Ed25519 signature encodes 2 points on an elliptical curve, but won't fit into our
969973
# 256-bit <data>, so hash it (along with the document). The result is a "fingerprint" of the

0 commit comments

Comments
 (0)