Stealth in Science: Leveraging Zero-Knowledge Proofs to Safeguard Drug Design Intellectual Property
Tags: security, web3, cybersecurity, code
Published: 2023-07-01 08:25:16

In this blog, we'll explore how the intellectual property (IP) of drugs is protected while also making sure they are safe for use.

We use a cryptographic protocol called zkSNARK. In case if you aren't aware of it, [Intro to ZK](https://dev.to/yagnadeepxo/unlocking-zero-knowledge-proofs-from-beginner-to-advanced-38p)

Imagine this scenario: a drug's safety depends on certain secret parameters known only to the designer. However, the designer faces a challenge—they must demonstrate the drug's safety without divulging these confidential details.

vaccines may have specific chemical parameters that need to be considered to ensure human safety. These parameters can include:

**Adjuvants:**
Aluminum salts (e.g., aluminum hydroxide, aluminum phosphate) used as adjuvants in vaccines typically have a concentration range of 0.2-1.25 milligrams per milliliter (mg/mL) or as per specific regulatory requirements.

**Preservatives:**
Thimerosal, a mercury-containing compound used as a preservative in some vaccines, has a typical concentration range of 0.01-0.5 milligrams per milliliter (mg/mL) or as per specific regulatory requirements. It's worth noting that thimerosal-free vaccine formulations are also available for most vaccines.

**Stabilizers:**
The concentration of stabilizers used in vaccines can vary depending on the specific substance. Common stabilizers such as sugars (e.g., sucrose) and proteins (e.g., human serum albumin) can be present in the range of 0.1-5% w/v (weight/volume) or as per specific requirements.

**Excipients:**
Excipients in vaccines can have various concentration limits depending on their nature and purpose. For example, the concentration of certain excipients like sodium chloride (salt) may range from 0.5-9 milligrams per milliliter (mg/mL), while others may have different limits based on their specific role in the vaccine formulation.

The problem here is while generating cryptographic proofs we cannot give float datatype values to the circuit, because cryptographic circuit uses modular math.
The solution for this is we can convert the float values to integers by multiplying specific scalar value (ex: 100, 1000).

Now let's design the circuit.

The circuit design involves checking the values of the parameters and determining if the values lie within the permitted range. If yes the circuit gives out 1(true), else 0(false),this will be the witness.

```
pragma circom 2.1.5;
include "../node_modules/circomlib/circuits/comparators.circom";
template VaccineParamsCheck() {
    signal input preservative;
    signal input adjuvant;
    signal input stabilizer;
    signal input excipient;
    signal output isValid;

    signal preservative_valid;
    signal adjuvant_valid;
    signal stabilizer_valid;
    signal excipient_valid;

    component LT1 = LessThan(10);
    component GT1 = GreaterThan(10);

    component LT2 = LessThan(10);
    component GT2 = GreaterThan(10);

    component LT3 = LessThan(12);
    component GT3 = GreaterThan(12);

    component LT4 = LessThan(12);
    component GT4 = GreaterThan(12);

    LT1.in[0] <== preservative;
    LT1.in[1] <== 50;

    GT1.in[0] <== preservative;
    GT1.in[1] <== 1;

    preservative_valid <== LT1.out*GT1.out;

    LT2.in[0] <== adjuvant;
    LT2.in[1] <== 125;

    GT2.in[0] <== adjuvant;
    GT2.in[1] <== 20;

    adjuvant_valid <== LT2.out*GT2.out;

    LT3.in[0] <== stabilizer;
    LT3.in[1] <== 500;

    GT3.in[0] <== stabilizer;
    GT3.in[1] <== 10;

    stabilizer_valid <== LT3.out*GT3.out;

    LT4.in[0] <== excipient;
    LT4.in[1] <== 900;

    GT4.in[0] <== excipient;
    GT4.in[1] <== 50;

    excipient_valid <== LT4.out*GT4.out;

     signal int1 <== preservative_valid*adjuvant_valid;
     signal int2 <== stabilizer_valid*adjuvant_valid;
    
    isValid <== int1*int2;
    
}
component main = VaccineParamsCheck();
```
The provided code represents a vaccine parameter checking mechanism. It ensures that specific parameters of a vaccine, such as preservative, adjuvant, stabilizer, and excipient, fall within acceptable ranges without revealing the actual values. The goal is to verify if the vaccine parameters are safe for human use without disclosing sensitive information.

The code uses templates and components to compare the input values with predefined thresholds. It employs comparators like LessThan and GreaterThan to evaluate if each parameter is within the desired range.The cryptographic circuit can perform checks only in a certian way so the compartor components are used from circomlib

```
template LessThan(n) {
    assert(n <= 252);
    signal input in[2];
    signal output out;

    component n2b = Num2Bits(n+1);

    n2b.in <== in[0]+ (1<<n) - in[1];

    out <== 1-n2b.out[n];
}
```

```
template GreaterThan(n) {
    signal input in[2];
    signal output out;

    component lt = LessThan(n);

    lt.in[0] <== in[1];
    lt.in[1] <== in[0];
    lt.out ==> out;
}

```

The signals preservative_valid, adjuvant_valid, stabilizer_valid, and excipient_valid indicate whether each respective parameter passes the validity check.

The code also performs logical operations to combine the validity results of different parameters. The signals int1 and int2 represent intermediate checks, and isValid is the final output determining if the combination of parameters meets the safety criteria.

_In conclusion, this blog provided an overview of a privacy-preserving mechanism for checking vaccine parameters. By utilizing templates and components, the code allows the verification of essential parameters without disclosing sensitive information. This approach ensures that the vaccine's safety can be determined without revealing the exact values of the parameters._