Skip to content

Commit

Permalink
Fix FIO obt data encryption/decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-edge committed Jan 11, 2025
1 parent f5f6080 commit 1c8e693
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## 4.32.4 (2024-12-25)

- fixed: Set correct Thorchain fee parameters when sending.
- fixed: (FIO) OBT data encryption/decryption

## 4.32.3 (2024-12-25)

Expand Down
44 changes: 26 additions & 18 deletions src/fio/FioEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,20 @@ export class FioEngine extends CurrencyEngine<FioTools, SafeFioWalletInfo> {
privateKeys: JsonObject,
...rest: any[]
): Promise<ObtData[]> => {
const obtDecoder = new GetObtData({
fioPublicKey: this.walletInfo.keys.publicKey,
getEncryptKey: this.defaultGetEncryptKey,
includeEncrypted: false
})
const encryptedObtData = await this.fetchEncryptedObtData(
'getObtData',
obtDecoder
const fioSdk = new FIOSDK(
privateKeys.fioKey,
this.walletInfo.keys.publicKey,
this.networkInfo.historyNodeUrls,
this.fetchCors
)
obtDecoder.privateKey = privateKeys.fioKey
obtDecoder.publicKey = this.walletInfo.keys.publicKey
const decryptedObtData: { obt_data_records: ObtData[] } =
(await obtDecoder.decrypt({
obt_data_records: encryptedObtData,
more: 0
})) ?? { obt_data_records: [] }

return decryptedObtData.obt_data_records

const res = await fioSdk.genericAction('getObtData', {
limit: 100,
offset: 0,
includeEncrypted: true
})

return res.obt_data_records ?? []
}
}
}
Expand Down Expand Up @@ -1704,12 +1700,24 @@ export class FioEngine extends CurrencyEngine<FioTools, SafeFioWalletInfo> {
hash: undefined,
offline_url: undefined
}

const fioSdk = new FIOSDK(
privateKeys.fioKey,
this.walletInfo.keys.publicKey,
this.networkInfo.historyNodeUrls,
this.fetchCors
)

const { encrypt_public_key: encryptPublicKey } =
await fioSdk.getEncryptKey(payeeFioAddress)

const cipherContent = transactions.getCipherContent(
'record_obt_data_content',
content,
fioPrivateKeys.fioKey,
payerPublicAddress
encryptPublicKey
)

txParams = {
account: 'fio.reqobt',
action: 'recordobt',
Expand Down

0 comments on commit 1c8e693

Please sign in to comment.