checkStealthAddress
Checks if an Announce
event is intended for the user by comparing the derived stealth address with the user's stealth address.
Import
import { checkStealthAddress } from "@scopelift/stealth-address-sdk";
Usage
import { checkStealthAddress } from "@scopelift/stealth-address-sdk";
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x..."
});
// true
Return Value
- Type:
boolean
Returnstrue
if the derived stealth address matches the user's stealth address, indicating the announcement is intended for the user; returnsfalse
otherwise.
Parameters
ephemeralPublicKey
-
Type:
HexString
The ephemeral public key from the announcement.
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x...",
});
schemeId
-
Type:
VALID_SCHEME_ID
The scheme ID used during the stealth address generation.
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x...",
});
spendingPublicKey
-
Type:
HexString
The user's spending public key.
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x...",
});
userStealthAddress
-
Type:
EthAddress
The user's stealth address, against which the derived address is compared.
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x...",
});
viewingPrivateKey
-
Type:
HexString
The user's viewing private key used to derive the shared secret.
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x...",
});
viewTag
-
Type:
HexString
The view tag from the announcement, used to quickly filter announcements not intended for the user.
const isForUser = checkStealthAddress({
ephemeralPublicKey: "0x...",
schemeId: 1,
spendingPublicKey: "0x...",
userStealthAddress: "0x...",
viewingPrivateKey: "0x...",
viewTag: "0x...",
});