@@ -704,7 +704,7 @@ const makeBootstrapObject = (
704704 const {
705705 signedGive,
706706 receivingSession,
707- receivingSide : receiverKeyForExporter ,
707+ receivingSide : peerIdFromHandoffReceive ,
708708 handoffCount,
709709 } = handoffReceive ;
710710 const { object : handoffGive , signature : handoffGiveSig } = signedGive ;
@@ -721,11 +721,12 @@ const makeBootstrapObject = (
721721 `${ label } : Bootstrap withdraw-gift: No peer public key for session id: ${ toHex ( sessionId ) } . This should never happen.` ,
722722 ) ;
723723 }
724+ const peerIdFromSession = makePublicKeyId ( peerPublicKey ) ;
724725 if (
725- compareByteArrays ( peerPublicKey . bytes , receiverKeyForExporter ) !== 0
726+ compareByteArrays ( peerIdFromSession , peerIdFromHandoffReceive ) !== 0
726727 ) {
727728 throw Error (
728- `${ label } : Bootstrap withdraw-gift: Receiver key mismatch. ` ,
729+ `${ label } : Bootstrap withdraw-gift: Receiver key mismatch for session ${ toHex ( sessionId ) } .\n peerIdFromSession: ${ toHex ( peerIdFromSession ) } \n peerIdFromHandoffReceive: ${ toHex ( peerIdFromHandoffReceive ) } ` ,
729730 ) ;
730731 }
731732 if ( compareByteArrays ( sessionId , receivingSession ) !== 0 ) {
@@ -1078,21 +1079,28 @@ export const makeOcapn = (
10781079
10791080 /** @type {MakeHandoff } */
10801081 const makeHandoff = signedGive => {
1082+ // We are the Receiver.
1083+ // This peer is the Gifter.
1084+ // The Exporter is specified by location in the HandoffGive.
1085+ const gifterLocation = peerLocation ;
10811086 const {
10821087 object : { exporterLocation } ,
10831088 } = signedGive ;
10841089 return HandledPromise . resolve (
10851090 ( async ( ) => {
10861091 const [ receiverGifterSession , receiverExporterSession ] =
10871092 await Promise . all ( [
1088- provideSession ( peerLocation ) ,
1093+ provideSession ( gifterLocation ) ,
10891094 provideSession ( exporterLocation ) ,
10901095 ] ) ;
10911096 const {
10921097 ocapn,
10931098 id : receiverExporterSessionId ,
1094- self : { keyPair : receiverExporterKey } ,
1099+ self : { keyPair : receiverKeyForExporter } ,
10951100 } = receiverExporterSession ;
1101+ const receiverPeerIdForExporter = makePublicKeyId (
1102+ receiverKeyForExporter . publicKey ,
1103+ ) ;
10961104 const {
10971105 self : { keyPair : receiverGifterKey } ,
10981106 } = receiverGifterSession ;
@@ -1102,7 +1110,7 @@ export const makeOcapn = (
11021110 signedGive ,
11031111 handoffCount ,
11041112 receiverExporterSessionId ,
1105- receiverExporterKey . publicKey ,
1113+ receiverPeerIdForExporter ,
11061114 receiverGifterKey ,
11071115 ) ;
11081116 return E ( bootstrap ) [ 'withdraw-gift' ] ( signedHandoffReceive ) ;
0 commit comments