
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
bitmark-lib
Advanced tools
$ npm install bitmark-lib
var bitmarkLib = require('bitmark-lib');
var Seed = bitmarkLib.Seed;
Seed is where everything starts for an entity which wants to use bitmark services. A seed is used to generate:
To create a new random seed:
var seed = new Seed();
There are 2 optional parameters for the Seed constructor: network and version. The default for network is livenet, and the only supported version now is 1.
var seed = new Seed('testnet');
var seed = new Seed('testnet', 1);
Losing the seed means losing the control over bitmarks and assets of the entity. Thus, a seed should be backed up by saving its string format in a secure place, and be imported when there are operations which require authentication or encryption.
var backup = seed.toString(); // using toBase58 is equivalent
var restore = Seed.fromString(backup);
var isValidSeedString = Seed.isValid(backup); // check whether a string is in valid format
Passing a counter to the seed, it will create a new 32-byte secret key
var key = seed.generateKey(999);
Note: the counter 999 and 1000 are preserved to generate auth key and encryption key
toString)livenet or testnetvar AuthKey = bitmarkLib.AuthKey;
To create the auth key from a new seed:
var authKey = AuthKey.fromSeed(new Seed());
To instantiate a AuthKey object:
var authKey01 = new AuthKey();
There are 2 optional parameters for the AuthKey constructor: network and key type. The default for network is livenet, and the default for key type is ed25519.
var authKey02 = new AuthKey('testnet');
var authKey03 = new AuthKey('livenet', 'ed25519');
To parse the private key from the KIF string:
var authKey = AuthKey.fromKIF('cELQPQoW2YDWBq37V6ZLnEiHDD46BG3tEvVmj6BpiCSvQwSszC');
To parse the private key from buffer:
var authKey = AuthKey.fromBuffer('75d954e8f790ca792502148edfefed409d3da04b49443d390435e776821252e26c60fe96ba261d2f3942a33d2eaea2391dfb662de79bc0c4ef53521ce8b11c20', 'testnet', 'ed25519');
The buffer can be either a hexadecimal string or a Buffer object. For ed25519, we can input a seed (32 bytes) or a full private key (64 bytes).
livenet or testnet, depending on the keyed25519)var AccountNumber = bitmarkLib.AccountNumber;
To instantiate an AccountNumber object from an AuthKey:
var authKey = AuthKey.fromKIF('cELQPQoW2YDWBq37V6ZLnEiHDD46BG3tEvVmj6BpiCSvQwSszC');
var accountNumber = authKey.getAccountNumber()
To instantiate an AccountNumber object from an account number string:
var accountNumber = new AccountNumber('bxnT1iqAWFWM2MpSNGMHTq92Y27n81B3ep4vFcTpra4AEU9q7d');
var sameAccountNumber = AccountNumber.fromString('bxnT1iqAWFWM2MpSNGMHTq92Y27n81B3ep4vFcTpra4AEU9q7d');
To instantiate an AccountNumber object from a Buffer object:
var buffer = new Buffer('73346e71883a09c0421e5d6caa473239c4438af71953295ad903fea410cabb44', 'hex');
var accountNumber = new AccountNumber(buffer, 'testnet', 'ed25519');
var sameAccountNumber01 = AccountNumber.fromBuffer(buffer, 'testnet', 'ed25519');
var sameAccountNumber02 = AccountNumber.froMBuffer('73346e71883a09c0421e5d6caa473239c4438af71953295ad903fea410cabb44', 'testnet', 'ed25519');
Note:
network and keytype are optional, the defaults are livenet and ed25519.AccountNumber.isValid('erxs7Li15xcioSpGLi1kPhA4vNvJSJYEUnTzU4oJ989coEuUv;'); // returns false because of bad account number string
AccountNumber.isValid('ayUWeSeJEcATAHQTBU1qkVcEh9V12cnfCeFWAh1Jq7NdVMjH5q', 'testnet'); // returns false because of wrong network
AccountNumber.isValid('erxs7Li15xcioSpGLi1kPhA4vNvJSJYEUnTzU4oJ989coEuUvb', 'testnet'); // returns true
livenet or testnet, depending on the account numbered25519)var Asset = bitmarkLib.Asset
To instantiate an Asset record object:
var asset = new Asset()
.setName('Asset name')
.addMetadata('description', 'this is asset description')
.setFingerprint('73346e71883a09c0421e5d6caa473239c4438af71953295ad903fea410cabb44')
.sign(authKey);
true if the asset record is signedvar Issue = bitmarkLib.Issue
To instantiate an Issue record object:
var issue = new Issue()
.fromAsset(asset)
.setNonce(1)
.sign(authKey);
Note: fromAsset() can receive either an Asset object or an asset-id string.
true if the issue record is signedvar Transfer = bitmarkLib.Transfer
To instantiate a Transfer record object:
var transfer = new Transfer()
.fromTx(previousTransfer)
.toAccountNumber(newOwner)
.sign(authKey);
Note: fromTx() can receive either an Issue or Transfer object or an id string from either an Issue or Transfer object.
true if the transfer record is signedvar bitmarkLib = require('bitmark-lib');
var fingerprint = bitmarkLib.util.fingeprint;
--
Copyright (c) 2014-2017 Bitmark Inc (support@bitmark.com).
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FAQs
Bitmark library
We found that bitmark-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.