Skip to content

Commit

Permalink
test: add multisig-rotate-out-and-in.sh script
Browse files Browse the repository at this point in the history
shows commands to try to rotate larry out and curly in
  • Loading branch information
kentbull committed May 13, 2024
1 parent 4f44b98 commit 4192d81
Show file tree
Hide file tree
Showing 2 changed files with 349 additions and 15 deletions.
169 changes: 169 additions & 0 deletions scripts/demo/basic/multisig-rotate-out-and-in.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/bin/bash
# Creates three AIDs, larry, moe, and curly.
# Then, creates a multisig AID, threestooges, with larry and moe.
# Later, curly is rotated into the threestooges AID.
# Finally, larry is rotated out of the threestooges AID.

# Pull in colored text
source "${KERI_SCRIPT_DIR}"/demo/basic/script-utils.sh

# create keystores and AIDs for larry, moe, and curly
export LARRY=EKZYoeLcSpoBn7DdD0Rugk3xGy6in8zJvhJpMhZ23ETe
export MOE=EJ__4LOcMfGRU0V65ywo9GgczMkqTZtgjmCKWU06MDQR
export CURLY=EItXS2M_iaQvYRex9swUaCWLETsxFdQbQD0XZmbukKOV


# Step 1/5 Create AIDs
echo
print_yellow "Individual AID creation with file: ${KERI_DEMO_SCRIPT_DIR}/data/multisig-stooge.json"
# Larry Prefix EKZYoeLcSpoBn7DdD0Rugk3xGy6in8zJvhJpMhZ23ETe
kli init --name larry \
--salt 0ACDEyMzQ1Njc4OWxtbm9aBc \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--config-dir "${KERI_SCRIPT_DIR}" \
--config-file demo-witness-oobis
kli incept --name larry --alias larry \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--file "${KERI_DEMO_SCRIPT_DIR}/data/multisig-stooge.json"

# Moe Prefix EJ__4LOcMfGRU0V65ywo9GgczMkqTZtgjmCKWU06MDQR
kli init --name moe \
--salt 0ACDEyMzQ1Njc4OWdoaWpsaw \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--config-dir "${KERI_SCRIPT_DIR}" \
--config-file demo-witness-oobis
kli incept --name moe --alias moe \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--file "${KERI_DEMO_SCRIPT_DIR}/data/multisig-stooge.json"

# Curly Prefix EItXS2M_iaQvYRex9swUaCWLETsxFdQbQD0XZmbukKOV
kli init --name curly \
--salt 0ACDEyMzQ1Njc4OWdoaWpsaw \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--config-dir "${KERI_SCRIPT_DIR}" \
--config-file demo-witness-oobis
kli incept --name curly --alias curly \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--file "${KERI_DEMO_SCRIPT_DIR}/data/multisig-stooge.json"
echo


# Step 2/5 Add contacts with OOBIs
echo
print_yellow "Resolve OOBIs"
kli oobi resolve --name larry --oobi-alias moe \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--oobi http://127.0.0.1:5642/oobi/$MOE/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha
kli oobi resolve --name larry --oobi-alias curly \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--oobi http://127.0.0.1:5642/oobi/$CURLY/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha

kli oobi resolve --name moe --oobi-alias larry \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--oobi http://127.0.0.1:5642/oobi/$LARRY/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha
kli oobi resolve --name moe --oobi-alias curly \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--oobi http://127.0.0.1:5642/oobi/$CURLY/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha

kli oobi resolve --name curly --oobi-alias larry \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--oobi http://127.0.0.1:5642/oobi/$LARRY/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha
kli oobi resolve --name curly --oobi-alias moe \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--oobi http://127.0.0.1:5642/oobi/$MOE/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha
echo


# Step 3/5 Create multisig AID
echo
print_yellow "Multisig Inception for alias: threestooges with Larry and Moe"
print_yellow "Multisig Inception with file: ${KERI_DEMO_SCRIPT_DIR}/data/multisig-two-stooges.json"

# Follow commands run in parallel
print_yellow "Multisig Inception for Larry"
kli multisig incept --name larry --alias larry \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--group "threestooges" \
--file "${KERI_DEMO_SCRIPT_DIR}/data/multisig-two-stooges.json" &
pid=$!
PID_LIST+=" $pid"

print_yellow "Multisig Inception for Moe"
kli multisig incept --name moe --alias moe \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--group "threestooges" \
--file "${KERI_DEMO_SCRIPT_DIR}/data/multisig-two-stooges.json" &
pid=$!
PID_LIST+=" $pid"

echo
print_yellow "Multisig Inception - wait"
echo
wait $PID_LIST


# Check status for larry
kli status --name larry --alias threestooges --passcode "DoB26Fj4x9LboAFWJra17O"


# Step 4/5 rotate each individual keystore - required prior to performing rotation
kli rotate --name larry --alias larry --passcode "DoB26Fj4x9LboAFWJra17O"
kli rotate --name moe --alias moe --passcode "DoB26Fj4x9LboAFWJra17O"
kli rotate --name curly --alias curly --passcode "DoB26Fj4x9LboAFWJra17O"


# Step 5/5 Pull the latest keystate so each participant knows each other participant's key state
echo
print_yellow "Pull key state in from other multisig group participant identifiers"
kli query --name larry --alias larry --passcode "DoB26Fj4x9LboAFWJra17O" --prefix $MOE
kli query --name larry --alias larry --passcode "DoB26Fj4x9LboAFWJra17O" --prefix $CURLY
kli query --name moe --alias moe --passcode "DoB26Fj4x9LboAFWJra17O" --prefix $LARRY
kli query --name moe --alias moe --passcode "DoB26Fj4x9LboAFWJra17O" --prefix $CURLY
kli query --name curly --alias curly --passcode "DoB26Fj4x9LboAFWJra17O" --prefix $LARRY
kli query --name curly --alias curly --passcode "DoB26Fj4x9LboAFWJra17O" --prefix $MOE
echo


# Step 6/6 Rotate Curly into the threestooges AID
echo
print_yellow "Multisig rotation with alias: threestooges"

PID_LIST=""

print_yellow "Larry rotates - curly in"
kli multisig rotate --name larry --alias "threestooges" \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--isith '["1/2", "1/2"]' \
--smids $LARRY \
--smids $MOE \
--nsith '["1/3", "1/3", "1/3"]' \
--rmids $LARRY \
--rmids $MOE \
--rmids $CURLY &
pid=$!
PID_LIST+=" $pid"
print_yellow "Moe rotates - curly in"
kli multisig rotate --name moe --alias "threestooges" \
--passcode "DoB26Fj4x9LboAFWJra17O" \
--isith '["1/2", "1/2"]' \
--smids $LARRY \
--smids $MOE \
--nsith '["1/3", "1/3", "1/3"]' \
--rmids $LARRY \
--rmids $MOE \
--rmids $CURLY &
pid=$!
PID_LIST+=" $pid"

echo
print_yellow "Multisig rotation ${ALIAS} - wait"
wait $PID_LIST

# Check status for larry
kli status --name larry --alias threestooges --passcode "DoB26Fj4x9LboAFWJra17O"
# Check status for moe
kli status --name moe --alias threestooges --passcode "DoB26Fj4x9LboAFWJra17O"
# Check status for curly
kli status --name curly --alias threestooges --passcode "DoB26Fj4x9LboAFWJra17O"

print_green "Multisig rotation - complete"
Loading

0 comments on commit 4192d81

Please sign in to comment.