Skip to content

Commit 1fd2b90

Browse files
committed
Add chain_code config and integration CKD sign into e2e
1 parent 92da5f6 commit 1fd2b90

3 files changed

Lines changed: 361 additions & 1 deletion

File tree

e2e/config.test.yaml.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ nats:
1111
max_concurrent_keygen: 1
1212
max_concurrent_signing: 10
1313
session_warm_up_delay_ms: 500
14+
chain_code: "{{.CKDChainCode}}"

e2e/setup_test_identities.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ echo "🔐 Generating random password for badger encryption..."
2828
BADGER_PASSWORD=$(< /dev/urandom tr -dc 'A-Za-z0-9' | head -c 32)
2929
echo "✅ Generated password: $BADGER_PASSWORD"
3030

31+
# Generate chain_code (32-byte hex value, 64 hex characters)
32+
echo "🔐 Generating chain_code (32-byte hex)..."
33+
CHAIN_CODE=$(openssl rand -hex 32)
34+
echo "✅ Generated chain_code: $CHAIN_CODE"
35+
3136
# Generate config.test.yaml from template
3237
echo "📝 Generating config.test.yaml from template..."
3338
if [ ! -f "config.test.yaml.template" ]; then
@@ -43,6 +48,7 @@ ESCAPED_PASSWORD=$(printf '%s\n' "$BADGER_PASSWORD" | sed 's/[[\.*^$()+?{|]/\\&/
4348

4449
sed -e "s/{{\.BadgerPassword}}/$ESCAPED_PASSWORD/g" \
4550
-e "s/{{\.EventInitiatorPubkey}}/$TEMP_PUBKEY/g" \
51+
-e "s/{{\.CKDChainCode}}/$CHAIN_CODE/g" \
4652
config.test.yaml.template > config.test.yaml
4753

4854
echo "✅ Generated config.test.yaml from template"
@@ -106,20 +112,35 @@ if [ -f "test_event_initiator.identity.json" ]; then
106112
PUBKEY=$(cat test_event_initiator.identity.json | jq -r '.public_key')
107113
echo "📝 Updating config files with event initiator public key and password..."
108114

109-
# Update all test node config files with the actual public key and password
115+
# Update all test node config files with the actual public key, password, and chain_code
110116
for i in $(seq 0 $((NUM_NODES-1))); do
111117
# Update public key using sed with | as delimiter (safer than /)
112118
sed_inplace "s|event_initiator_pubkey:.*|event_initiator_pubkey: $PUBKEY|g" "$BASE_DIR/test_node$i/config.yaml"
113119
# Update password using sed with | as delimiter and escaped password
114120
sed_inplace "s|badger_password:.*|badger_password: $ESCAPED_PASSWORD|g" "$BASE_DIR/test_node$i/config.yaml"
121+
# Update chain_code
122+
if grep -q '^\s*chain_code:' "$BASE_DIR/test_node$i/config.yaml"; then
123+
sed_inplace "s|chain_code:.*|chain_code: \"$CHAIN_CODE\"|g" "$BASE_DIR/test_node$i/config.yaml"
124+
else
125+
printf '\nchain_code: "%s"\n' "$CHAIN_CODE" >> "$BASE_DIR/test_node$i/config.yaml"
126+
fi
115127
done
116128

117129
# Also update the main config.test.yaml
118130
sed_inplace "s|event_initiator_pubkey:.*|event_initiator_pubkey: $PUBKEY|g" "$BASE_DIR/config.test.yaml"
119131
sed_inplace "s|badger_password:.*|badger_password: $ESCAPED_PASSWORD|g" "$BASE_DIR/config.test.yaml"
132+
# Update chain_code in config.test.yaml if it was replaced with placeholder
133+
if grep -q '{{\.CKDChainCode}}' "$BASE_DIR/config.test.yaml" 2>/dev/null; then
134+
sed_inplace "s|{{\.CKDChainCode}}|$CHAIN_CODE|g" "$BASE_DIR/config.test.yaml"
135+
elif grep -q '^\s*chain_code:' "$BASE_DIR/config.test.yaml"; then
136+
sed_inplace "s|chain_code:.*|chain_code: \"$CHAIN_CODE\"|g" "$BASE_DIR/config.test.yaml"
137+
else
138+
printf '\nchain_code: "%s"\n' "$CHAIN_CODE" >> "$BASE_DIR/config.test.yaml"
139+
fi
120140

121141
echo "✅ Event initiator public key updated: $PUBKEY"
122142
echo "✅ Badger password updated: $BADGER_PASSWORD"
143+
echo "✅ Chain code updated: $CHAIN_CODE"
123144
else
124145
echo "❌ Failed to generate event initiator identity"
125146
exit 1

0 commit comments

Comments
 (0)