PageSourceSearch

https://noir-lang.org/docs/assets/js/c423f7a4.70b779d6.js

js noir-lang.org collected 2026-10-03 22:50:58 UTC 4,149 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[1185],{61612(e,s,r){r.r(s),r.d(s,{assets:()=>d,contentTitle:()=>l,default:()=>b,frontMatter:()=>a,metadata:()=>n,toc:()=>o});const n=JSON.parse('{"id":"libraries/standard_library/bn254","title":"Bn254 Field Library","description":"Optimized helpers for bn254 Fr\u2014fast comparisons and decomposition tailored for Noir\u2019s standard library.","source":"@site/versioned_docs/version-v1.0.0-beta.26/libraries/standard_library/bn254.md","sourceDirName":"libraries/standard_library","slug":"/libraries/standard_library/bn254","permalink":"/docs/v1.0.0-beta.26/libraries/standard_library/bn254","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-beta.26/libraries/standard_library/bn254.md","tags":[],"version":"v1.0.0-beta.26","frontMatter":{"title":"Bn254 Field Library","description":"Optimized helpers for bn254 Fr\u2014fast comparisons and decomposition tailored for Noir\u2019s standard library."},"sidebar":"sidebar","previous":{"title":"Black Box Functions","permalink":"/docs/v1.0.0-beta.26/libraries/standard_library/black_box_fns"},"next":{"title":"Bounded Vectors","permalink":"/docs/v1.0.0-beta.26/libraries/standard_library/containers/boundedvec"}}');var t=r(74848),i=r(28453);const a={title:"Bn254 Field Library",description:"Optimized helpers for bn254 Fr\u2014fast comparisons and decomposition tailored for Noir\u2019s standard library."},l=void 0,d={},o=[{value:"decompose",id:"decompose",level:2},{value:"assert_gt",id:"assert_gt",level:2},{value:"assert_lt",id:"assert_lt",level:2},{value:"gt",id:"gt",level:2},{value:"lt",id:"lt",level:2}];function c(e){const s={code:"code",h2:"h2",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.p,{children:["Noir provides a module in standard library with some optimized functions for bn254 Fr in ",(0,t.jsx)(s.code,{children:"std::field::bn254"}),"."]}),"\n",(0,t.jsx)(s.h2,{id:"decompose",children:"decompose"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-rust",children:"fn decompose(x: Field) -> (Field, Field) {}\n"})}),"\n",(0,t.jsx)(s.p,{children:"Decomposes a single field into two fields, low and high. The low field contains the lower 16 bytes of the input field and the high field contains the upper 16 bytes of the input field. Both field results are range checked to 128 bits."}),"\n",(0,t.jsx)(s.h2,{id:"assert_gt",children:"assert_gt"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-rust",children:"fn assert_gt(a: Field, b: Field) {}\n"})}),"\n",(0,t.jsxs)(s.p,{children:["Asserts that a > b. This will generate less constraints than using ",(0,t.jsx)(s.code,{children:"assert(gt(a, b))"}),"."]}),"\n",(0,t.jsx)(s.h2,{id:"assert_lt",children:"assert_lt"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-rust",children:"fn assert_lt(a: Field, b: Field) {}\n"})}),"\n",(0,t.jsxs)(s.p,{children:["Asserts that a < b. This will generate less constraints than using ",(0,t.jsx)(s.code,{children:"assert(lt(a, b))"}),"."]}),"\n",(0,t.jsx)(s.h2,{id:"gt",children:"gt"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-rust",children:"fn gt(a: Field, b: Field) -> bool  {}\n"})}),"\n",(0,t.jsx)(s.p,{children:"Returns true if a > b."}),"\n",(0,t.jsx)(s.h2,{id:"lt",children:"lt"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-rust",children:"fn lt(a: Field, b: Field) -> bool  {}\n"})}),"\n",(0,t.jsx)(s.p,{children:"Returns true if a < b."})]})}function b(e={}){const{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},28453(e,s,r){r.d(s,{R:()=>a,x:()=>l});var n=r(96540);const t={},i=n.createContext(t);function a(e){const s=n.useContext(i);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function l(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),n.createElement(i.Provider,{value:s},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.