Updated Ragger tests to use the new private CAL key
This commit is contained in:
2
.github/workflows/ci-workflow.yml
vendored
2
.github/workflows/ci-workflow.yml
vendored
@@ -270,8 +270,6 @@ jobs:
|
||||
sudo apt install -y qemu-user-static
|
||||
|
||||
- name: Run tests
|
||||
env:
|
||||
CAL_SIGNATURE_TEST_KEY: ${{ secrets.CAL_SIGNATURE_TEST_KEY }}
|
||||
run: |
|
||||
cd tests/ragger
|
||||
. ./venv/bin/activate
|
||||
|
||||
18
tests/ragger/cal/cal.py
Normal file
18
tests/ragger/cal/cal.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
import hashlib
|
||||
from ecdsa.util import sigencode_der
|
||||
from ecdsa import SigningKey
|
||||
|
||||
_key: SigningKey = None
|
||||
|
||||
def _init_key():
|
||||
global _key
|
||||
with open(os.path.dirname(__file__) + "/key.pem") as pem_file:
|
||||
_key = SigningKey.from_pem(pem_file.read(), hashlib.sha256)
|
||||
assert _key != None
|
||||
|
||||
def sign(data: bytes) -> bytes:
|
||||
global _key
|
||||
if not _key:
|
||||
_init_key()
|
||||
return _key.sign_deterministic(data, sigencode=sigencode_der)
|
||||
@@ -1,14 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
import re
|
||||
import hashlib
|
||||
from ecdsa import SigningKey
|
||||
from ecdsa.util import sigencode_der
|
||||
from ethereum_client.client import EthereumClient, EIP712FieldType
|
||||
import base64
|
||||
from cal import cal
|
||||
|
||||
# global variables
|
||||
app_client: EthereumClient = None
|
||||
@@ -254,7 +251,7 @@ def send_filtering_message_info(display_name: str, filters_count: int):
|
||||
for char in display_name:
|
||||
to_sign.append(ord(char))
|
||||
|
||||
sig = sig_ctx["key"].sign_deterministic(to_sign, sigencode=sigencode_der)
|
||||
sig = cal.sign(to_sign)
|
||||
app_client.eip712_filtering_message_info(display_name, filters_count, sig)
|
||||
|
||||
# ledgerjs doesn't actually sign anything, and instead uses already pre-computed signatures
|
||||
@@ -272,7 +269,7 @@ def send_filtering_show_field(display_name):
|
||||
to_sign.append(ord(char))
|
||||
for char in display_name:
|
||||
to_sign.append(ord(char))
|
||||
sig = sig_ctx["key"].sign_deterministic(to_sign, sigencode=sigencode_der)
|
||||
sig = cal.sign(to_sign)
|
||||
app_client.eip712_filtering_show_field(display_name, sig)
|
||||
|
||||
def read_filtering_file(domain, message, filtering_file_path):
|
||||
@@ -299,9 +296,6 @@ def init_signature_context(types, domain):
|
||||
global sig_ctx
|
||||
|
||||
handle_optional_domain_values(domain)
|
||||
env_key = os.environ["CAL_SIGNATURE_TEST_KEY"]
|
||||
key = base64.b64decode(env_key).decode() # base 64 string -> decode bytes -> string
|
||||
sig_ctx["key"] = SigningKey.from_pem(key, hashlib.sha256)
|
||||
caddr = domain["verifyingContract"]
|
||||
if caddr.startswith("0x"):
|
||||
caddr = caddr[2:]
|
||||
|
||||
Reference in New Issue
Block a user