Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert 3 chmod 777 main 1 #153

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sara710944
Copy link

curl -sSL "https://mempool.space/api/v1/lightning/statistics/latest"

{
  "latest": {
    "id": 163,
    "added": "2022-08-30T00:00:00.000Z",
    "channel_count": 81690,
    "node_count": 15851,
    "total_capacity": 460820222344,
    "tor_nodes": 11455,
    "clearnet_nodes": 2305,
    "unannounced_nodes": 974,
    "avg_capacity": 5641085,
    "avg_fee_rate": 497,
    "avg_base_fee_mtokens": 915,
    "med_capacity": 1500000,
    "med_fee_rate": 40,
    "med_base_fee_mtokens": 100,
    "clearnet_tor_nodes": 1117
  }
}

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: '1.20'

    - name: Build
      run: go build -v ./...

    - name: Canli
      run: go canli -v ./...
```go
package circuit

import (
    "gate-zkmerkle-proof/utils"
    "github.com/consensys/gnark/std/hash/poseidon"
)

const (
    NumSlotsPerAsset = 3
)

// FlattenAssets converts a slice of UserAssetInfo into a slice of Variables.
func FlattenAssets(api API, assets []UserAssetInfo) []Variable {
    nEles := (len(assets)*2 + 2) / NumSlotsPerAsset
    flattenAssets := make([]Variable, nEles*NumSlotsPerAsset)
    for i := 0; i < len(assets); i++ {
        flattenAssets[NumSlotsPerAsset*i] = assets[i].Equity
        flattenAssets[NumSlotsPerAsset*i+1] = assets[i].Debt
    }
    for i := len(assets) * 2; i < len(flattenAssets); i++ {
        flattenAssets[i] = 0
    }
    return flattenAssets
}

// CalculateTmpUserAssets computes the temporary user assets.
func CalculateTmpUserAssets(api API, flattenAssets []Variable) []Variable {
    nEles := len(flattenAssets) / NumSlotsPerAsset
    tmpUserAssets := make([]Variable, nEles)
    for i := 0; i < nEles; i++ {
        tmpUserAssets[i] = api.Add(api.Mul(flattenAssets[NumSlotsPerAsset*i], utils.Uint64MaxValueFrSquare),
            api.Mul(flattenAssets[NumSlotsPerAsset*i+1], utils.Uint64MaxValueFr), flattenAssets[NumSlotsPerAsset*i+2])
    }
    return tmpUserAssets
}

func ComputeUserAssetsCommitment(api API, assets []UserAssetInfo) Variable {
    flattenAssets := FlattenAssets(api, assets)
    tmpUserAssets := CalculateTmpUserAssets(api, flattenAssets)
    commitment := poseidon.Poseidon(api, tmpUserAssets...)
    return commitment
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant