BitVM Club
WhitepaperBTC Layer2BitVMBTC 2024 EventMedia
  • Introduction
  • BitVM
    • BitVM Whitepaper PDF
    • BitVM Whitepaper Word
    • BitVM Introduction
    • BitVM-FAQ
  • Resources
    • BitVM And Its Optimization Considerations
    • PPT
      • BitVM Slides by Cartesi,Bringing ZK verifiers to Bitcoin using BitVM - ?
      • How BitVM works?
      • BitVM : Off-chain Bitcoin Contracts
    • Primer
      • What is BitVM? And why does it matter to rollups?
      • BitVM: Ushering in a New Era of Bitcoin Computations
      • BitVM: A Computational Revolution in Bitcoin
      • Is BitVM the Next Evolution for Smart Contracts on Bitcoin?
      • What is BitVM? A Beginner’s Guide to Turing-Complete Bitcoin Smart Contracts
      • Simple explanation of BitVM
      • BitVM Primer
      • Things BitVM needs
      • BitVM explained in 4 slides
      • THE BIG DEAL WITH BITVM: ARBITRARY COMPUTATION NOW POSSIBLE ON BITCOIN WITHOUT A FORK
      • Deep dive into BitVM -Computing paradigm to express Turing-complete Bitcoin contracts-
    • Youtube
      • Robin Linus on BitVM
      • What is BitVM? with Robin Linus and Super Testnet (SLP520)
      • Ark Whiteboard Masterclass with Burak & Robin
      • BitVM Intro: Create Logic Gates and Circuits in Python
      • Demo of Robin Linus's implementation of BitVM
      • BitVM 8 bit CPU: Write Bitcoin programs in Assembly
      • BitVM 8 bit CPU: Assembly Quirks
      • BitVM 8 bit CPU: Write Bitcoin programs in Assembly
      • How bitvm works: from logic gates to an 8bit cpu for bitcoin
      • S15 E13: Robin Linus on BitVM & Permissionless Bitcoin Development
      • BitVM: Uma Ferramenta Para Contratos Ainda Mais Inteligentes - Super Testnet - Satsconf 2023
      • BTC生态浏览超70万次的BitVM到底是什么? | 11月8日更新了什么?
      • BitVM 在比特币上实现智能合约
      • Bitcoin Smart Contracts and BitVM
    • Twitter
      • BitVM and MATT
      • Script, Taproot and BitVM
  • Devlopment
    • Libraries
    • Tutorial
      • STARK proof for BitVM circuit execution
      • BitVM and sCrypt
      • BitVM Rust Implementation
  • BTC Layer2
    • Exploring the Landing Paths for Bitcoin Layer 2 Ecosystem
  • BitVM Project
    • Overview
    • Bitlayer
      • Introduction
      • Technical Introduction
    • Citrea
      • Technical Introduction
      • Introducing Citrea: Bitcoin’s First ZK Rollup
    • ZKBase
      • ZKByte: A Trustless Bitcoin Layer2 Scaling Solution based on Zero Knowledge and BitVM
    • Bitstake
      • Introducing Bitstake: A proof of stake bridge based on BitVM
  • BitVM Weekly Report
    • 2025.3.10 - 2025.3.16
    • 2025.3.3 - 2025.3.9
    • 2025.2.24 - 2025.3.2
    • 2025.2.17 - 2025.2.23
    • 2025.2.10 - 2025.16
    • 2025.1.20 - 2025.2.2
    • 2025.1.13 - 2025.1.19
    • 2025.1.6 - 2025.1.12
    • 2024.12.30 - 2025.1.5
    • 2024.12.23 - 2024.12.29
    • 2024.12.16 - 2024.12.22
    • 2024.12.9- 2024.12.15
    • 2024.12.2- 2024.12.8
    • 2024.11.25 - 2024.12.1
    • 2024.11.18 - 2024.11.24
    • 2024.11.11 - 2024.11.17
    • 2024.11.4 - 2024.11.10
    • 2024.10.28 - 2024.11.3
    • 2024.10.21 - 2024.10.27
    • 2024.10.14 - 2024.10.20
    • 2024.10.7 - 2024.10.13
    • 2024.9.23 - 2024.10.6
    • 2024.9.16 - 2024.9.22
    • 2024.9.9 - 2024.9.15
    • 2024.9.2 - 2024.9.8
    • 2024.8.26 - 2024.9.1
    • 2024.8.19 - 2024.8.25
    • 2024.8.13 - 2024.8.19
    • 2024.8.5 - 2024.8.11
    • 2024.7.22 - 2024.7.28
    • 2024.7.15 - 2024.7.21
    • 2024.7.8 - 2024.7.14
    • 2024.7.1 - 2024.7.7
    • 2024.6.24 - 2024.6.30
    • 2024.6.10 - 2024.6.16
    • 2024.6.3 - 2024.6.9
    • 2024.5.27 - 2024.6.2
    • 2024.5.20 - 2024.5.26
    • 2024.5.13 - 2024.5.19
    • 2024.5.6 - 2024.5.12
    • 2024.3.18 - 2024.3.24
    • 2024.3.11 - 2024.3.17
    • 2024.3.4 - 2024.3.10
    • 2024.2.26 - 2024.3.3
  • BTC Layer2 Weekly Report
    • BTC Layer2 Projects Overview
    • 2024.3.11 - 2024.3.17
    • 2024.3.4 - 2024.3.10
    • 2024.2.26–2024.3.3
  • BTC 2024 Conferences
    • Bitcoin Renaissance 2024 Segmented By Keynotes & Panel
Powered by GitBook
On this page

Was this helpful?

  1. Devlopment
  2. Tutorial

BitVM and sCrypt

PreviousSTARK proof for BitVM circuit executionNextBitVM Rust Implementation

Last updated 1 year ago

Was this helpful?

original:

Invitation to Bitcoin Developers: Utilize sCrypt for Advanced BitVM Implementations

To the Bitcoin Development Community,

In light of the recent advancements in BTC's computational capabilities introduced by , we are extending an open invitation to explore the integration of sCrypt as a language for developing BitVM scripts. BitVM represents a significant advancement in Bitcoin's scripting capabilities, enabling Turing-complete contracts within the existing BTC framework.

Technical Overview:

BitVM facilitates off-chain computation, essential for complex contract execution while maintaining Bitcoin's on-chain efficiency. While Assembly (ASM) scripts are so far used to express contracts for BitVM, they present certain limitations in terms of readability and broader accessibility.

, a high-level language based on TypeScript tailored for Bitcoin smart contracts, offers a more efficient and streamlined approach for developers. The language's design aligns with traditional programming paradigms, enhancing understandability and maintainability of scripts.

Example of Gate Commitment in sCrypt:

type HashPair = {
    hash0: Ripemd160
    hash1: Ripemd160
}

export class DemoBitVM extends SmartContract {
    @prop()
    hashPairA: HashPair

    @prop()
    hashPairB: HashPair

    @prop()
    hashPairE: HashPair

    constructor(
        hashPairA: HashPair,
        hashPairB: HashPair,
        hashPairE: HashPair,
    ) {
        super(...arguments)
        this.hashPairA = hashPairA
        this.hashPairB = hashPairB
        this.hashPairE = hashPairE
    }

    @method()
    public openGateCommit(
        preimageA: ByteString,
        preimageB: ByteString,
        preimageE: ByteString,
    ) {
        const bitA = this.bitValueCommit(this.hashPairA, preimageA)
        const bitB = this.bitValueCommit(this.hashPairB, preimageB)
        const bitE = this.bitValueCommit(this.hashPairE, preimageE)
        assert(this.nand(bitA, bitB) == bitE)
    }

    @method()
    bitValueCommit(hashPair: HashPair, preimage: ByteString): boolean {
        const h = hash160(preimage)
        assert (h == hashPair.hash0 || h == hashPair.hash1)
        return h == hashPair.hash1
    }

    @method()
    nand(A: boolean, B: boolean): boolean {
        return !(A && B)
    }

}

The code above represents a simple gate commitment for BitVM. It has a single entry point, i.e. the public function "openGateCommit", which can be unlocked by providing the apporpriate hash preimages of the commitments.

The code compiles into a bitcoin script, the function of which is analogous to the script described in the BitVM whitepaper (Figure 2):

// Reveal Preimage of hashE0 or hashE1
<hashE0/1>
OP_BITCOMMITMENT
OP_TOALTSTACK
// Now the bit value of "E" is on the stack
// Reveal Preimage of hashB0 or hashB1
<hashB0/1>
OP_BITCOMMITMENT
OP_TOALTSTACK
// Now the bit value of "B" is on the stack
// Reveal Preimage of hashA0 or hashA1
<hashA0/1>
OP_BITCOMMITMENT
OP_TOALTSTACK
// Now the bit value of "A" is on the stack
//
// Verify that "A NAND B == E"
//
// Read "B" from alt stack
OP_FROMALTSTACK
// Compute A NAND B
OP_NAND
// Read "E" from alt stack
OP_FROMALTSTACK
// Check A NAND B == E
OP_EQUALVERIFY

The equivalent is expressed in sCrypt as:

const bitA = this.bitValueCommit(this.hashPairA, preimageA)
const bitB = this.bitValueCommit(this.hashPairB, preimageB)
const bitE = this.bitValueCommit(this.hashPairE, preimageE)
assert(this.nand(bitA, bitB) == bitE)

Invitation and Objectives:

  1. Examination of sCrypt: We encourage the exploration of sCrypt's features and syntax. Its alignment with conventional programming languages positions it as a viable candidate for BitVM script development.

  2. Contribution Using sCrypt: Contributions in sCrypt to the BitVM ecosystem are highly encouraged. Such endeavors would ease the utilization of BTC's full scripting capabilities.

  3. Technical Exchange and Collaboration: The advancement of BitVM and sCrypt requires collective efforts in knowledge exchange and technical collaboration. We welcome insights from both experienced and emerging developers in the Bitcoin community.

Sincerely,

Mihael Šinkec, sCrypt Inc.

For more information about sCrypt, please refer to .

https://gist.github.com/msinkec/5827d5285a18de8930324f67b880841e
BitVM
sCrypt
the official documentation