
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
GASP (Graph Aware Sync Protocol) is a protocol designed to synchronize transaction data between two parties in a blockchain environment. It ensures the legitimacy and completeness of transaction data using a recursive reconciliation method.
To install the GASP library, run:
npm i @bsv/gasp
For now, check out the GASP test suite to see how GASP works.
The below code is for reference only, and will probably not work (it is untested). Check back later for links to examples where GASP is implemented.
Here's a basic example demonstrating how to use the GASP library:
import { GASP, GASPStorage, GASPRemote, GASPInitialRequest, GASPNode } from '@bsv/gasp';
// Mock implementation of the storage interface for demonstration purposes
class ExampleGASPStorage implements GASPStorage {
private utxos: Array<{ txid: string; outputIndex: number; rawTx: string; timestamp?: number }> = [];
constructor(utxos: Array<{ txid: string; outputIndex: number; rawTx: string; timestamp?: number }>) {
this.utxos = utxos;
}
async findKnownUTXOs(since: number): Promise<Array<{ txid: string; outputIndex: number }>> {
return this.utxos
.filter(utxo => utxo.timestamp && utxo.timestamp > since)
.map(utxo => ({ txid: utxo.txid, outputIndex: utxo.outputIndex }));
}
async hydrateGASPNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode> {
const found = this.utxos.find(utxo => utxo.txid === txid && utxo.outputIndex === outputIndex);
if (!found) {
throw new Error('UTXO not found');
}
return {
graphID,
rawTx: found.rawTx,
outputIndex: found.outputIndex,
// In a real implementation, you would return real proofs and metadata
proof: metadata ? 'example_proof' : undefined,
txMetadata: metadata ? 'example_tx_metadata' : undefined,
outputMetadata: metadata ? 'example_output_metadata' : undefined,
};
}
async findNeededInputs(tx: GASPNode): Promise<{ requestedInputs: Record<string, { metadata: boolean }> } | void> {
// In a real scenario, this method would analyze the transaction inputs and determine if more information is needed
return; // Assuming no additional inputs are needed for simplicity
}
async appendToGraph(tx: GASPNode, spentBy?: string): Promise<void> {
console.log(`Appending transaction to graph: ${tx.txid} at output index ${tx.outputIndex}`);
}
async validateGraphAnchor(graphID: string): Promise<void> {
console.log(`Validating graph anchor for graph ID: ${graphID}`);
}
async discardGraph(graphID: string): Promise<void> {
console.log(`Discarding graph with ID: ${graphID}`);
}
async finalizeGraph(graphID: string): Promise<void> {
console.log(`Finalizing graph with ID: ${graphID}`);
}
}
// Example implementation of the remote interface
class ExampleGASPRemote implements GASPRemote {
private remoteStorage: ExampleGASPStorage;
constructor(remoteStorage: ExampleGASPStorage) {
this.remoteStorage = remoteStorage;
}
async getInitialResponse(request: GASPInitialRequest): Promise<{ UTXOList: Array<{ txid: string; outputIndex: number }> }> {
return { UTXOList: await this.remoteStorage.findKnownUTXOs(request.since) };
}
async requestNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode> {
return this.remoteStorage.hydrateGASPNode(graphID, txid, outputIndex, metadata);
}
}
// Initializing storages and remotes for two participants: Alice and Bob
const aliceStorage = new ExampleGASPStorage([
{ txid: 'tx1', outputIndex: 0, rawTx: '010000...', timestamp: 162005 },
{ txid: 'tx2', outputIndex: 1, rawTx: '020000...', timestamp: 162010 }
]);
const bobStorage = new ExampleGASPStorage([]);
const bobRemote = new ExampleGASPRemote(aliceStorage);
const alice = new GASP(aliceStorage, bobRemote);
// Simulate synchronization process
(async () => {
try {
await alice.sync();
console.log('Synchronization between Alice and Bob completed successfully.');
} catch (error) {
console.error('Failed to synchronize:', error);
}
})()
The license for the code in this repository is the Open BSV License.
FAQs
Graph Aware Sync Protocol
The npm package @bsv/gasp receives a total of 73 weekly downloads. As such, @bsv/gasp popularity was classified as not popular.
We found that @bsv/gasp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.