NillionNetwork / nada-by-example

Learn the Nada language by working with example Nada programs
https://docs.nillion.com/nada-by-example
MIT License
11 stars 8 forks source link

Implement standard deviation #11

Closed Davetbutler closed 2 months ago

Davetbutler commented 2 months ago

Description

Implement a nada program that computes the standard deviation of an array of SecretIntegers

Use Case

This is a commonly used math function, and thus we should have an example for others to use rather than write the nada program from scratch.

Specific Requirements

The nada program should have one party, whose input is a SecretInteger and output the standard deviation of the input array.

DIM = 10

def nada_main():
    party1 = Party(name="Party1")

    num = na.array([DIM], party1, "num", SecretInteger)

    # compute the standard deviation

    return na.output(standard_deviation, party1, "standard_deviation")

To do this, you will likely need the square root function that has already been implemented as an example in this repo.