npm

@onflow/util-encode-key
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

Encode Key

Encodes public keys so that the Flow Blockchain can use them.

You can learn more about keys, curves, hashes, weights and signing here: https://github.com/onflow/flow/blob/master/docs/content/concepts/accounts-and-keys.md#supported-signature--hash-algorithms

import { template as addNewKey } from "@onflow/six-add-new-key"
import * as fcl from "@onflow/fcl"

import {encodeKey, ECDSA_P256, SHA3_256} from "@onflow/util-encode-key"

// The key you want to use to sign transactions later
const PUBLIC_KEY = "0bfcd8790c3ce88f3fac9d4bd23514f48bf0cdd1f6c3c8bdf87b11489b1bbeca1ef805ec2ee76451e9bdb265284f78febaeacbc8b0827e0a7baafee4e655d0b5"

const ENCODED_KEY = encodeKey(
  PLUBLIC_KEY, // The key to encode (DER Hex)
  ECDSA_P256,  // The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1]
  SHA3_256,    // The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256]
  1000         // The weight you want this key to have [Range: 0..1000]
)

const authz = fcl.currentUser().authorization

const resp = await fcl.send([
  addNewKey({
    publicKey: [ENCODED_KEY],
    proposer: authz,
    payer: authz,
    authorization: authz
  })
])

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.3-multisig.00multisig
1.2.3164latest
1.2.4-alpha.02alpha
1.2.0-typescript.02typescript
1.2.2-event-streaming.11event-streaming

Version History

VersionDownloads (Last 7 Days)Published
1.2.4-alpha.02
1.2.3164
1.2.283
1.2.2-alpha.21
1.2.2-alpha.11
1.2.2-alpha.01
1.2.2-event-streaming.11
1.2.2-event-streaming.01
1.2.120
1.2.0-typescript.02
1.2.01
1.2.0-alpha.02
1.1.072
1.1.0-alpha.40
1.1.0-alpha.30
1.1.0-alpha.20
1.1.0-alpha.10
1.1.0-alpha.00
1.0.33
1.0.20
1.0.2-alpha.00
1.0.10
1.0.00
1.0.0-alpha.10
1.0.0-alpha.00
0.0.3-multisig.00
0.0.2281
0.0.10
0.0.00

Package Sidebar

Install

npm i @onflow/util-encode-key

Homepage

onflow.org

Weekly Downloads

635

Version

1.2.3

License

Apache-2.0

Unpacked Size

36.8 kB

Total Files

14

Last publish

Collaborators

  • sisyphussmiling
  • bthaile
  • jribbink
  • nialexsan
  • han210
  • gregorggg
  • chasefleming
  • dapperj
  • gregsantos
  • dapper_labs
  • jeffreydoyle
  • harry.eth
  • turbolent_flow