forked from polkadot-js/extension
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
20 changed files
with
1,597 additions
and
22 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/extension-base/src/background/RequestBytesDecrypt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019-2021 @polkadot/extension authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import type { KeyringPair } from '@polkadot/keyring/types'; | ||
import type { DecryptPayloadRaw } from '@polkadot/types/types'; | ||
import type { RequestDecrypt } from './types'; | ||
import type { HexString } from '@polkadot/util/types'; | ||
|
||
import { wrapBytes } from '@polkadot/extension-dapp/wrapBytes'; | ||
import { TypeRegistry } from '@polkadot/types'; | ||
import { u8aToHex, hexToU8a } from '@polkadot/util'; | ||
|
||
export default class RequestBytesDecrypt implements RequestDecrypt { | ||
public readonly payload: DecryptPayloadRaw; | ||
|
||
constructor (payload: DecryptPayloadRaw) { | ||
this.payload = payload; | ||
} | ||
|
||
decrypt (_registry: TypeRegistry, pair: KeyringPair, recipientPublicKey: HexString | string | Uint8Array): { decrypted: string } { | ||
console.log("pair", pair); | ||
console.log("this.payload.data", this.payload.data); | ||
console.log("wrapBytes(this.payload.data)", wrapBytes(this.payload.data)); | ||
console.log("recipientPublicKey", recipientPublicKey); | ||
return { | ||
decrypted: u8aToHex( | ||
pair.decryptMessage( | ||
hexToU8a(this.payload.data), recipientPublicKey | ||
) | ||
) | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.