PTLCs: The Standard(?)

Great work sir!!

For anyone looking to test this out, these are the instructions I followed:

  1. Setup devnet on linux
  2. Run the ptlc test

Here is the expected output

App: Start
Bob: Start
Alice: Start
Bob: Hello from Alice
Bob: Receive wallet addressA
Alice: Hello from Bob
Alice: Send wallet addressA
Alice: Receive wallet addressB
Bob: Send wallet addressB
Alice: Generate key pair (a1, A1), (a2, A2), (ra, Ra) and (t, T)
Bob: Generate key pair (b1, B1), (b2, B2) and (rb, Rb)
Bob: Receive public key (A1, A2, Ra, T)
Alice: Send public key (A1, A2, Ra, T)
Bob: Send public key (B1, B2, Rb)
Alice: Receive public key (B1, B2, Rb)
Alice: Create joint public key (A1 + B1), (A2 + B2), (Ra + T) and (Rb + T)
Alice: Create PTLC1: send funds, expiration and public key (A2 + B2) as Ed25519 point lock
Bob: Create joint public key (A1 + B1), (A2 + B2), (Ra + T) and (Rb + T)
Bob: Receive PTLC1 id
Alice: Wait 2 momentums
Alice: Send ptlc1 id
Alice: Receive ptlc2 id
Bob: Verify PTLC1 funds, expiration and public key
Bob: Create PTLC2: send funds, expiration and public key (A1 + B1) as Ed25519 point lock
Bob: Wait 2 momentums
Bob: Send PTLC2 id
Bob: Create message msgA: SHA3(PTLC2 id + addressA)
Bob: Create message msgB: SHA3(PTLC1 id + addressB)
Bob: Receive challenge (c1 * a1) and (c2 * a2)
Alice: Create message msgA: SHA3(PTLC2 id + addressA)
Alice: Create message msgB: SHA3(PTLC1 id + addressB)
Alice: Generate challenge (c1 = SHA512((Rb + T) || (A1 + B1) || msgA))
Alice: Generate challenge (c2 = SHA512((Ra + T) || (A2 + B2) || msgB))
Alice: Send challenge (c1 * a1) and (c2 * a2)
Bob: Receive challenge (c1 * a1) and (c2 * a2)
Bob: Generate challenge (c1 = SHA512((Rb + T) || (A1 + B1) || msgA))
Bob: Generate challenge (c2 = SHA512((Ra + T) || (A2 + B2) || msgB))
Alice: Receive challenge ((c2a2 + c2) * b2)
Bob: Send challenge ((c2a2 + c2) * b2)
Bob: Receive adapter signature (s_adapt_b = (ra + c2a2b2))
Alice: Send adaptor signature (s_adapt_b = (ra + c2a2b2))
Alice: Receive adaptor signature (s_adapt_a = (rb + c1a1b1))
Bob: Verify adapter signature (s_adapt_b * G == (c2 * (A2 + B2) + Ra))
Bob: Send adaptor signature (s_adapt_a = (rb + c1a1b1))
Bob: Receive signature (sa)
Alice: Create signature (sa = s_adapt_a + t)
Alice: Verify signature (sa * G == c1 * (A1 + B1) + Rb + T)
Alice: Create ed25519 signature (sa64 = bytes64(Rb + T, sa))
Alice: Unlock PTLC2 with signature (sa64)
Alice: Wait 2 momentums
Alice: End
Bob: Extract (t = sa - s_adapt_a)
Bob: Create signature (sb = s_adapt_b + t)
Bob: Verify signature (sb * G == c2 * (A2 + B2) + Ra + T)
Bob: Create ed25519 signature (sb64 = bytes64(Ra + T, sb))
Bob: Unlock PTLC1 with signature (sb64)
Bob: Wait 2 momentums
Bob: End
App: End
3 Likes